multidimensional-array

How do I initialize a C# array with dimensions decided at runtime?

Hi, and thanks for looking. I have a 2D c# array, that has 50 as one of its dimensions. The other dimension depends on the number of rows in a database somewhere and is decided at runtime. How would I go about initializing an array like this? Currently my initialization for a single row looks like this, but I'm sure there's a better wa...

help using php explode () and organizing output

Can someone pls show me how to map this correctly? I am trying to understand how to use php explode() and organizing the values in a way that I can retrieve and print them in some organized matter. For each record I want to put a name=value in a particular bucket. I have (7) max buckets per record. Sometimes I have records that won't fi...

Multidimensional array

How to get stored the value entered by user in multidimensional array ...

Deleting object from array

i'm working on app for iphone on objective-c i have array with object references If i remove item with object reference from array should i release this object additionally or it will be removed from memory automatically? ...

Array diff of specific key within multi-dimensional array

I have two arrays of products, both formatted exactly the same, like so: $products = array( [0] => array( ['product_id'] => 33 ['variation_id'] => 0 ['product_price'] => 500.00 ), [1] => array( ['product_id'] => 48 ['variation_id'] => 0 ['product_price'] => 600.00 ), ) I ...

processing 2 dimension array

Hi, I am working in classic ASP; using getRows to get multidimension array of rows and column. while iterating a row; I want to pass that single row into another function to build the column layout. with C# I can do this: obj[][] multiDimArray = FunctionCall_To_InitializeArray_4X16(); for (int rowId = 0 ; rowId < 4 ; rowId++) { Funct...

how to traverse a 2-d javascript array both hierarchically and vertically - recursively

A tree is formed from a 2-d javascript array. The first dimension is the no of levels in the tree (vertical) and the second dimension is the the no of nodes in each level.Every node in the tree has got a check box.A node will be shown as checked if all its children are checked.All that code is written. Now, if some nodes in the tree are...

How can I implement a custom reorganization function that returns a nested array?

I have this data coming from a database which pulls all subcategories and relevant info: $data = array( array( 'destination_name' => 'Ohio Resort', 'destination_slug' => 'ohio', 'subcategory_name' => 'Bird Hunting', 'subcategory_slug' => 'bird-hunting', 'category_name' => 'Hunting', 'c...

Problems accessing a variable which is casted into pointer to array of int with ctypes in python.

Hi there, I have C code which uses a variable data, which is a large 2d array created with malloc with variable size. Now I have to write an interface, so that the C functions can be called from within Python. I use ctypes for that. C code: FOO* pytrain(float **data){ FOO *foo = foo_autoTrain((float (*)[])data); return foo; } ...

dynamic 2D arrays in C / Objc

Hey guys I was wondering how I should do dynamic arrays in objc. Currently I have a function I wrote called malloc2D that looks like this: void* malloc2D(size_t unitSize, uint firstCount, uint secondCount){ void** pointer = malloc(sizeof(id) * firstCount); for (int i =0; i < firstCount; i ++){ pointer[i] = malloc(unitSize * second...

What is the best way to save a matrix of Checkboxes when x/y are not known until runtime?

I need to keep checkboxes in a collection and access them via matrix coordinates. The following example works but only if I know the size of the matrix beforehand, since an array is used. What would be the best kind of approach/collection to achieve the same result but also allow the matrix to be defined at runtime, e.g. Dictionary<>, ...

Most optimal way to reverse search list of similar strings

I have a list of data that includes both command strings as well as the alphabet, upper and lowercase, totaling to 512+ (including sub-lists) strings. I want to parse the input data, but i cant think of any way to do it properly other than starting from the largest possible command size and cutting it down until i find a command that is ...

Baffling Index-Out-Of-Bounds

There a section in my code where I need to invert a matrix. That can only reasonably be done on a square matrix, in this case a 3x3 square matrix. The tool I'm using to invert the matrix kept saying that my array wasn't a proper square. So I did a little test: double[,] x = new double[3, 3]; MessageBox.Show(x.GetLength(0).ToString())...

perl - help with hash and dumping of records

I have a perl script that is only keeping the last set of records for a named set and I have more than one set of records. So its over writing the data in the hash and just keeping the last set. I need help in printing out all the records. Thanks! Here's a copy of my script: #!/usr/local/bin/perl use strict; use warnings; use Data::D...

How can I convert this string into a multidimensional JavaScript array

I have a function which receives a string parameter, I need to convert this into an array. For example: var param = "['Presidente', '', ''], ['Gerente de Operaciones', 'Presidente', ''], ['Gerente de Ventas', 'Presidente', '']"; function myFunc(data){ // DoSomethingHere } myFunc(param); I need to convert data into an array, in thi...

Why two asterisks while accessing an element of 2-D array using pointers?

In C, when we access a[i][j] using pointers why do we need the second * in *(*(a + i) + j)? Using printf() I see a + i and *(a + i) print the same value. ...

PHP - Automatically creating a multi-dimensional array

So here's the input: $in['a--b--c--d'] = 'value'; And the desired output: $out['a']['b']['c']['d'] = 'value'; Any ideas? I've tried the following code without any luck... $in['a--b--c--d'] = 'value'; // $str = "a']['b']['c']['d"; $str = implode("']['", explode('--', key($in))); ${"out['$str']"} = 'value'; ...

Grid data structure

Usually ‘expandable’ grids are represented as list of lists (list of rows, each row has list of cells) and those lists are some kind of linked lists. Manipulating (removing, inserting) rows in this data structure is easy and inexpensive, it’s just matter of re-linking previous nodes, but when it comes to columns, for instance removing...

Rotating 64 CCSprites more efficiently?

I have an 8 by 8 matrix of sprites that I need to be able to rotate all of them 90 degrees at once. The way I've done it is using nested for loops, and a 2 dimensional array of sprite pointers. for(row = 0;row<9;row++){ for(column = 0;column<8;column++){ [trolls[row][column] runAction:[RotateBy actionWithDuration:0.01 an...

Finding a value inside a nested array having only a string with the keys

Hi, I have one array that contains some settings that looks like basically like this: $defaults = array( 'variable' => 'value', 'thearray' => array( 'foo' => 'bar' 'myvar' => array('morevars' => 'morevalues'); ); ); On another file, i get a string with the first level key a...