arrays

Why does this map return a single number?

Hello! I am trying to cut down on the number of code lines I am using but am ending up with a fairly simple problem (although it's stumping me since I am just starting to wrap my head around references) I am trying to concatenate several values in a particular order.. My code looks like this.. my $separator = ":"; my @vals = qw(name la...

Overhead of a .NET array?

I was trying to determine the overhead of the header on a .NET array (in a 32-bit process) using this code: long bytes1 = GC.GetTotalMemory(false); object[] array = new object[10000]; for (int i = 0; i < 10000; i++) array[i] = new int[1]; long bytes2 = GC.GetTotalMemory(false); array[0] = null; // ensure no garbage collectio...

When to use a List over an Array in Java?

In Java, when would it be preferential to use a List rather than an Array? ...

create an array from similarly named id's

I have a group of id's with similar names (ex: div1, div2, div3) that are all going to perform the same function. is there an easy way in jQuery to create an array by calling the prefix of the id ("div")? ...

Alternate use of the Array() function in VBA?

We generally use the array function is VBA as : Dim A As Variant A = Array("B", 1) This will give me the first element in A as "B" and second element as 1 However I want to decide the contents of A at run-time so is it possible for me to do something like Dim str As String Dim A As Variant str = "name, Sam" A = Array(str) When I...

Finding duplicates in an NSMutableArray

I have a class (colorClass) which holds 2 NSStrings (idNumber and favoriteColor). There is an NSMutableArray (arrayColor) that holds over 50,000 colorClass objects. What is the fastest way to find all duplicate idNumbers from all colorClass objects and return them in an array? Right now I'm using 1 for loop that goes copies arrayColor...

Distinguishing extra element from two arrays?

One of my friend was asked this question in an interview - You have given two integer arrays each of size 10. Both contains 9 equal elements (say 1 to 9) Only one element is different. How will you find the different element? What are different approaches you can take? One simple but lengthy approach would be - sort both arrays,...

Fastest/One-liner way to remove duplicates (by key) in Ruby Array?

What's the fastest/one-liner way to remove duplicates in an array of objects, based on a specific key:value, or a result returned from a method? For instance, I have 20 XML Element nodes that are all the same name, but they have different "text" values, some of which are duplicates. I would like to remove the duplicates by saying "if e...

Initialize Array to Blank custom type OCAML

ive set up a custom data type type vector = {a:float;b:float}; and i want to Initialize an array of type vector but containing nothing, just an empty array of length x. the following let vecarr = Array.create !max_seq_length {a=0.0;b=0.0} makes the array init to {a=0;b=0} , and leaving that as blank gives me errors. Is what im t...

convert encoding

hi all just wrote this: <?php function unicodeConvert($str) { header('Content-Type:text/html; charset=UTF-8'); $entityRef = array('"' => "&quot;", "&" => "&amp;", '¢' => "&cent;", '¤' => "&curren;", '¦' => "&brvbar;", '¨' => "&uml;", 'ª' => "&ordf;", '¬' => "&not;", '®' => "&reg;", '°' => "&deg;", '²' => "&sup2;", '´' => "&acut...

Array inside an array PHP SQL

I have tried everything I can think of for the last two days. I'm truly lost. I need to get this line of code to change based on my database. I have tried everything I could find on php.net and many forums. $Myday=>array('/index.php?day=$Myday&year=$MYyear','linked-day'), Any ideas or help would be much appericated $SQL = "SELE...

Load a range of arrays (C#)

I need to keep track of how many items are in a node of this one attribute in C# and I have no idea on how to load an array, starting with 1 and ending with a variable The code for this portion is this //Loads file containing OSXInstaller File List doc.Load("Distribution.xml"); XmlNodeList ChoiceNode = doc.GetElementsByTagName("choice"...

Create array from the contents of <div> tags in php

I have the contents of a web page assigned to a variable $html Here's an example of the contents of $html: <div class="content">something here</div> <span>something random thrown in <strong>here</strong></span> <div class="content">more stuff</div> How, using PHP can I create an array from that that finds the contents of <div class="...

Array to Hash or 2 binary element Array

I'm seeking the most concise way to do this Given the following Array: ['a','b','c'] how to get this: {'a'=> 1,'b'=> 2, 'c'=> 3} and [['a',1],['b',2],['c',3]] I have few solutions at mind, just want to see yours :) ...

Passing Static arrays as parameters for Dynamic arrays in Delphi

Hi dudes, I have this array: const / var _Data : array [0..4] of array [0..3] of Double = ((0,0,0,0), (0,0,1,1), (1,0,1,0), (1,1,0,0), (1,1,1,1)); I wanna pass it as param value for this procedure: procedure NN.NetTraining(Data: TDoubleMatrix); Where: TDoubleArray = array of Double; TDoubleMatri...

how to split multiple strings

Hi guys, im currently having troubles on my codes in C#. I want to split strings with no fix values. here' my code please help me fix this. protected void GridViewArchives_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drView = (DataRowView)e.Row.DataI...

Filtering array values in php?

How can i filter this array values with [category] => 1 [0] => Array ( [link] => index [image] => spot [category] => 0 ) [1] => Array ( [link] => test [image] => spotless [category] => 0 ) [2] => Array ( [link] => differentcat [image] => spotly ...

How could a pointer to a structure be an array?

This is really a noob quick question. Imagine you have a struct called "No" and the following piece of code: No *v_nos; // What does this mean? Where I took this from they were calling "v_nos" a array? Isn't it simply a pointer to a struct "No"? Thanks. ...

What's the most elegant way to bubble-sort in C#?

Can this be cleaned up? using System; class AscendingBubbleSort { public static void Main() { int i = 0,j = 0,t = 0; int []c=new int[20]; for(i=0;i<20;i++) { Console.WriteLine("Enter Value p[{0}]:", i); c[i]=int.Parse(Console.ReadLine()); } // Sortin...

Java: How to be sure to store unique arrays based on its values on a List

I have a number of one dimension arrays of Object[] (these objects are primitive types if it helps) I want to store these arrays in a List, but only the arrays whose contents are unique from the rest. My first aproximation was to iterate througth the arrays storing in a Set the value of Arrays.hashCode(array) and only storing the array...