arrays

resize dynamically array

Hello, I want to resize my array dynamic. Everything would be ok, but in example I find someone use Array.Resize() to resize one dimension array, but I want to have possibility create jagged array. I read from file line, in which it could be some numbers separate by space - therefore i need jagged array created dynamic. It's my class whe...

What's the easiest way to get Dictionary functionality in VB.NET?

I want to statically define a mapped array of strings like: var dict = {cat:50, bat:10, rat:30}; and lookup values within it like: MessageBox.Show( dict["cat"] ) ...

Insert doubles in cell array into vector in Matlab

How can I take the first row of a cell array that contains doubles and insert it into a vector, without using a 'for' loop? ...

php - get the first key for an element?

I'm trying to add an extra class tag if an element / value is the first one found in an array. The problem is, I don't really know what the key will be... A minified example of the array Array ( [0] => Array( id => 1 name = Miller ) [1] => Array( id => 4 nam...

Passing Data From Initial XML Request To Subsequent Pages

`I am working with an API that sends back an XML response upon request. Here's a simplified example: <buildings> <building attr1="foo" attr2="bar"> <uri>http://blah.com&lt;/uri&gt; <thumbnail>http://blah.com/foo-picture.jpg&lt;/thumbnail&gt; </building> <building attr1="poo" attr2="pee"> ... </building> </bu...

Grouping array values in php.

Hello, I have an array with some value like this: [Organization_id] => Array ( [0] => 4 [1] => 4 [2] => 4 ) but i want some thing like this: [Organization_id] => Array ( [0] => 4 ) Thanks in advance.. ...

add custom to mysql_fetch_assoc results array

Hello there - is it possible to add custom data to the results so it can be used the same as the $results being returned? ie i'd like to add a random number to the results; $recordSet = mysql_query($sql,$this->conn); $results = array(); while ($row = mysql_fetch_assoc($recordSet)){ $results[]=$row; /// add to results[] a custom...

How to store an array returned by a method in Java

Hello everyone. I want to store the array returned by a method into another array. How can I do this? public int[] method() { int z[] = {1,2,3,5}; return z; } When I call this method, how I can store the array returned (z) into another array. ...

[PHP] array_diff & renumbering numeric keys

(I'm a beginner) My script uses the standard $c = 0; $t = count($array); while ($c < $t) { $blah = $array[$c]; ++$c; } rather extensively. But I just ran into a situation where I also need array_diff and it breaks that all to hell because now the numeric keys have gaps. I'm getting Undefined offset errors all over the place. H...

Total number of repetition of array value in PHP.

Hello, I have an array like: [Organization_id] => Array ( [0] => 4 [1] => 4 [2] => 2 [3] => 4 [4] => 2 [5] => 4 [6] => 4 [7] => 4 [8] => 2 ) Now i just want to know that how many times the vale '4' & '2' does...

PHP fixed arrays of data...performance issues

Hello I have a telephone area code to Time zone array of several hundred elements. Is this array built at run time or at compile time. John ...

Ruby Array find_first object ?

Hi, Am I missing something in the Array documentation? I have an array which contains up to one object satisfying a certain criterion. I'd like to efficiently find that object. The best idea I have from the docs is this: candidates = my_array.select { |e| e.satisfies_condition? } found_it = candidates.first if !candidates.empty? B...

C# quickest way to shift array

How can i quickly shift all the items in an array one to the left, padding the end with null? [0,1,2,3,4,5,6] would become [0,2,3,4,5,6,null] Edit: I said quickly but I guess I meant efficiently. I need to do this without creating a List or some other data structure. This is something I need to do several hundred thousand times in as s...

Sphinx search filter to handle arrays

I have a database of objects which have each been assigned to multiple categories. I am using sphinx search to search the products but would also like to filter the results to only objects that match an array of categories. ...

Multiple assignment of non-tuples in scala

Just to clarify, when I say multiple assigment, parallel assignment, destructuring bind I mean the following pattern matching gem scala> val (x,y) = Tuple2("one",1) x: java.lang.String = one y: Int = 1 which assigns "one" to x and 1 to y. I was trying to do val (x,y) = "a b".split() I was expecting that scala would attempt to patt...

How to create and use a multi-dimensional Array in Scala 2.8

Hello everyone, in Scala 2.8 how do I create an array of multiple dimensions? For example I want an integer or double matrix, something like double[][] in java. I know for a fact that arrays have changed in 2.8 and that the old arrays are deprecated, but are there multiple ways to do it now and if yes, which is best? Hoping for quick ...

Is there an issue in C with malloc and MPI?

Hi all, Sorry I cannot post any source code... I have a code running a master/slave red-black algorithm for a G.S. solver. In the simple case, the matrix is split into 4 evenly sized computational pieces. The images 1-3 perform their part of the computation, and send back buffers with the results to image 0. The problem is this: I hav...

MATLAB: element-wise array replication according to a count

My question is similar to this one, but I would like to replicate each element according to a count specified in a second array of the same size. An example of this, say I had an array v = [3 1 9 4], I want to use rep = [2 3 1 5] to replicate the first element 2 times, the second three times, and so on to get [3 3 1 1 1 9 4 4 4 4 4]. S...

How to sort an array based on a specific field in the array?

How can I sort an array based on two specific values within the array? For instance: $arr = array( array('a' => array('field1' => 'Abc', 'field2' => 'Def'), 'b' => 0) array('a' => array('field1' => 'Ghi', 'field2' => 'Jkl'), 'b' => 0) ); I want to sort this array based on the $arr[$i]['a']['field1...

Select from mysql table WHERE field='$array' ?

If I have an array of say, some ID's of users. How could i do something like this: $array = array(1,40,20,55,29,48); $sql = "SELECT * FROM `myTable` WHERE `myField`='$array'"; Is there a simple way to do this, I thought about looping through array items and then building up one big "WHERE -- OR -- OR -- OR" statement but i thought tha...