arrays

iphone dev create an array accessable from a number of View Controllers

Hi All I have an array arryImages which I would only like to declare once and access it from a number of view controllers, but I can't figure out where to place it. I have a separate class (Variables.m) which contains the following code @implementation Variables //images array arryImages = [NSArray arrayWithObjects: [U...

Arrays Javascript

I seem to be going around in circles on something I know is really easy. But I must be having a bad day. I want to populate a 2d array dynamically. If I do it statically like this: arrChartValues = new Array(['Q1', 20], ['Q2', 10], ['Q3', 30]); But I want it to be in a loop inserting lots of pairs of values. Any ideas? Thanks Oli...

Arranging objects

I have a group of objects (UIImageViews) in an array. I want to arrange them by yvalues. The greater the y value, the smaller the number in the array. So the one at the top of the page will be the first in the array and the one at the bottom is the last in the array. They move around so every second or so the array will have to be re-arr...

How can I create an array of directory contents in Perl?

Hello! I need to make 3 arrays from the contents of $directory. The first one I can use: $var = qx{ls $directory}; print $var; However the second and third I want to grep for "Primary *" and "Secondary *" I've used the commands: my @primary = 0; my @secondary = 0; @primary = system("ls test_77 > test | grep Primary* test"); print...

Returning Array from ActiveX component to JavaScript

I have an ActiveX component (which I did not write and have no control over). It has several methods I want to use, which return arrays. Every time I attempt to do something of the sort: var arrayValue = axObj.methodWhichReturnsArray(); the arrayValue object is undefined. The component provider tells me that I should not be having any...

Ruby Select method (for an array) problemos

I'm running the following method and I'm successfully passing two arguments (inventory, quantity) into the method. However I'm incorrectly using .first and .each methods. I'm attempting to replace .each with the .select to select for the cart item with the Inventory id: 6 possible .each replacement: (does not function) inventory_to_incr...

Objective-C accessing / changing array elements in a multidimensional array (NSArray)

I'm trying to change a value in a multidimensional array but getting a compiler error: warning: passing argument 2 of 'setValue:forKey:' makes pointer from integer without a cast This is my content array: NSArray *tableContent = [[NSArray alloc] initWithObjects: [[NSArray alloc] initWithObjects:@"a",@"b",@"c",nil], ...

When to release an object added to an NSMutableDictionary

Hello. I am working on an iPhone app that will construct, at run-time, an NSMutableDictionary for which the values (of the key-value pairs) will be NSMutableArrays. Being somewhat new to the Objective-C, I am concerned that the following will cause a memory leak: - (void) addNewSupplierPhoto:(UIImage*)image toSupplierID:(NSInteger*) sup...

array_length in C

I wrote an array_length function like this: int array_length(int a[]){ return sizeof(a)/sizeof(int); } However it is returning 2 when I did unsigned int len = array_length(arr); printf ("%i" , len); where I have int arr[] = {3,4,5,6,1,7,2}; int * parr = arr; But when I just do int k = sizeof(arr)/sizeof(int); printf("%i", ...

Java Arrays - What are they

Hi From looking at the Java Collections API i see that arrays are not regarded as collections. If not what are arrays regarded as? ...

Adding ArrayList elements efficiently

How would I shorten this? int[] a1 = {2, 0, 1, 4, 3}; int[] a2 = {3, 1, 2, 0, 4}; int[] a3 = {4, 2, 3, 1, 0}; int[] a4 = {0, 3, 4, 2, 1}; int[] a5 = {1, 4, 0, 3, 2}; ArrayList<int[]> array = new ArrayList<int[]>(); array.add(a1); array.add(a2); array.add(a3); array.add(a4); array.add(a5); ...

xml parsing: tags should be in numerical array?

<?php /* Sample: $results = XMLParser::load('<xml ....'); $results = XMLParser::load(VSCHEMAS.'/Users.edit.xml'); */ /** * Abstract XMLParser class. A non-instantiable class that uses SimpleXML to parse XML, based on a path or body passed into the load method * * @abstract */ abstract class X...

Passing arrays vs structures to functions

In C, arrays are passed to functions as pointers. Structures can be passed to functions either by value or by address (pointer). Is there any specific reason why we can not pass array by value but we can pass structre by value ? ...

Editing an array in a class, from a modal view controller.

In my Tab Bar application, I want the user to have a list of items. in the nav bar, i have a button, that (hopefully) lets the user add items to this list. that button presents a modal view controller with a txt field, and a done button the list on the main page is a table view, with an array, as data source. i want the mvc to be ...

PHP: Array as var_export/include vs. (un)serialize vs. json_(en|de)code

I have to transfer a big array from one server to another using a file. It's a multidimensional, but quite simple array. Now I'm searching for the most efficient way, to get this file into my application on the second server. So this question is about the file->array part, not the array->file part on the first server. Of course I did so...

ArrayList and Array difference

With reference to MSDN, It is stated that "You can set the lower bound of an Array, but the lower bound of an ArrayList is always zero" If i declare an array a[10], the lower bound is always a[0]. Is this the lower bound specified there? If yes, How can we set the lower bound of an array, Since the index of an array always starts with...

PHP Traversing Function to turn single array into nested array with children - based on parent id

I have an array similar to this: Array ( Array ( [ID] => 1 [parentcat_ID] => 0 ), Array ( [ID] => 2 [parentcat_ID] => 0 ), Array ( [ID] => 6 [parentcat_ID] => 1 ), Array ( [ID] => 7 [parentcat_ID] => 1 ), Array ( ...

C++ passing arrays to a method problem

Hey there I have this function: void vdCleanTheArray(int (*Gen_Clean)[25]) { } I wanted to know what kind of array does it accepts and clear it. Sorry, I have a little knowledge in c++, someone just asked me. Thanks! ...

O(1) lookup in non-contiguous memory?

Is there any known data structure that provides O(1) random access, without using a contiguous block of memory of size O(N) or greater? This was inspired by this answer and is being asked for curiosity's sake rather than for any specific practical use case, though it might hypothetically be useful in cases of a severely fragmented heap....

Merging all sub-arrays with mutual elements into one sub-array

I need to find all sub-arrays which share any mutual element and merge them into one sub-array. (Implementing in Python but any algorithmic idea would be helpful) Multidimensional array structure: categories = {'car':['automobile','auto'], 'bike':['vehicle','motorcycle','motorbike','automobile'], 'software':[...