multidimensional-array

Searching multidimensional array for values, then outputting other values in array

Hi all, I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommen...

2D array using pointers

I am attempting to read a file with some random names in the format "ADAM","MARK","JESSIE" ..... I have some constraints, the file should be read in a function but should be accessible form the main function with no global variables. The file size and the no of names in the file are not known. This is what I have done till now. I have ...

Need efficient data mappings example for a ListView drill down in Android/Java

I'm pretty new to java programming and am looking to do basic data mappings. I have a ListView object with a simple data array setup like this: setListAdapter(new ArrayAdapter<String>(this, R.layout.my_list_xml, MY_DATA)); What I want to happen is when you click an item it goes to it's subcategory. I'm not worried about switching th...

Grouping a 2D array according to its values

I've been trying to get some display logic to behave and stay where it belongs and the code has turned into an interesting little problem that'd be nice to make a general solution for. Bear with me, it looks like a wall of text but I've tried to format it nicely with simple example data so it should be understandable after a quick ski...

In C/C++, is char* arrayName[][] a pointer to a pointer to a pointer OR a pointer to a pointer?

I understood multi-dimensional arrays as pointers to pointers, but perhaps I am wrong? For example, I though: char * var = char var[] char ** var = char* var[] or char var[][] char *** var = char var[][][] or char* var[][] or char** var[] Is this incorrect? I was confused because I saw a char*[][] cast as a char** in a simple...

Path finding in a multidimensional array

I sort of understand the concept of pathfinding and how a program looks for point B from point A in the most efficient manner and vaguely familiar with the concept of A*. But what if, instead of trying to find a way through the maze, you're trying to find the longest corridor in closed off maze where the corridor can not be on a diagonal...

How can I create a two-dimensional array in Perl?

I am currently trying to pass a matrix file that is 32 by 48 to a multi-dimensional array in Perl. I am able to access all of the values but am having issues accessing a specific value. I need to run specific statistics on each of the values, calculate zscore, subtract the mean from each value, penalize specific values et cetera. I tried...

Looping through Array PHP

Hi all, I'm trying to loop through a cURL array response to generate XML files. However, my generated files all seem to have exactly the same contents - I don't know if this is the right approach or if I should be using an array, but I can't seem to figure it out and could use some fresh eyes. Basically, I want each $playlist's contents...

php array combine

I have the next array: Array ( [0] => Array ( [id] => 160 [payment_period] => Monthly [plan_payment_type_id] => 171 [payment_type_id] => 4 ) [1] => Array ( [id] => 160 [payment_period] => Monthly [plan_payment_type_id] => ...

what's the safe way to fill multidimensional array using std::fill?

Here's what I'm using: class something { char flags[26][80]; } a; std::fill(&a.flags[0][0], &a.flags[0][0]+26*80, 0); (Update: I should have made it clear earlier that I'm using this inside a class.) ...

Multidimensional array and dllhijacking

I'am currently working on a tool which checks if your apps are vulnerable to dllhijacking. Anyway, there's a section in my code which doesn't look very elegant. Now there are just two sets, but I want to add some more. Is there another way instead of just adding for loops for each set? LPSTR szFileExtWireShark[] = {"airpcap.dll", ".bfr"...

Order/randomize/convert array in rails

Hi, I've got this: a = [[123,1],[124,1],[125,1],[126,2],[127,3],[128,3]] And I would like to turn a into b: ordered by value random within array of value // updated: b = [[124,123,125],[126],[128,127]] How to do this in ruby? Im using rails. ...

Java Design 2 dimensional array

I have a 2 dimensional array. Is it necessary to fix the size so that every row has the same number of columns? data = {{ 2, 6, 3, 3, 1 }, { 4, 6, 3, 7, 5 }, { 8, 3, 0, 0, 0}, { 13, 12, 0, 0, 0 }, { 5, 1, 3, 9, 5, 0}} ...

PHP / SQL Using data from previous query to query another table

Hi, I've been trying to work this our for a while, but having trouble. We have 4 tables consiting of, suppliers, supplier_areas, supplier_languages and supplier_products options. I am trying to make an advanced search where users can search members using any of the above. An example search may be all suppliers in a certain area that ...

High-performance C++ multi-dimensional arrays

I am looking for advice regarding high performance multi-dimensional array libraries/classes for C++. What I really need is: the ability to dynamically allocate arrays with a size determined at run-time the ability to access and modify single array values (fast) to be able to use simple array arithmetic such as array1 = array2 + 2 * ar...

Java : Resizing a multidimensional array.

I have a multidimensional array built from Strings that is initially created with the size [50][50], this is too big and now the array is full of null values, I am currently trying to remove these said null values, I have managed to resize the array to [requiredSize][50] but cannot shrink it any further, could anyone help me with this? I...

Learning C# Issues with Array (Array Data Vanishes)

This is likely a scoping issue but the following code dies. I build a multi-dimensional array from 2 classes, Cell and Map. The map is an X by Y sized grid of Cells. Pretty normal so far (I keep re-writing this same program when I learn a new language). For brevity I'll just post the classes and a basic test that reflects the error. When...

How do I get a reference to a single dimension of a Multidemensional Array in C#?

I've come across a problem where I'd like to create an Array table. That is a 2 dimensional array where the number of rows and columns are known at runtime before the table needs to be created. The number of columns is the same for all rows. Once the array is created I'd like to operate on just 1 dimension of that array. Perhaps pass...

PHP Array sorting using child nodes?

Ok I have the following array: Array ( [0] => Array ( [id] => 6 [name] => This Course [time] => 1288082700 [description] => blah blah . [link] => http://this.com/?g=5 [course] => 22 ) [1] => Array ( [id] => 2 [name] => Workshop [time] => 1287561600 ...

Fastest way of sorting this multidimensional array?

What is the fastest way of sorting this both alphabetically by country and numerically by date?: Array ( [JAPAN] => Array ( [2010-10-17] => 2 ) [CUBA] => Array ( [2010-10-16] => 9 ) [RUSSIAN FEDERATION] => Array ( [2010-10-16] => 26 [2010-10-17] => 6 [2010-10-18] => 2 ) ...