arrays

How to add data to TableView on iphone?

I defined an array for tableView's listData. NSArray *array = [[NSArray alloc] initWithObjects:@"Sleep", @"Bashful", @"Happy", nil]; self.listData = array; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; cell.text = [listData objectAtIndex:row]; Now I want to add more data to the tableview...

Is there a way to do this in one step?

$clients = $CLIENT->find($options); $client = $clients[0]; EDIT: I Realized i should be clearer. The $CLIENT->find always returns an array of objects, but I want one line of code that turns the array (that will only have 1 object) into just an object. ...

Do 2D arrays use more resources than 1D arrays in Java?

For example, would a full int[50][8] use more resources (RAM and CPU) than 8 full int[50] arrays? ...

When listing information from a database using php and mysql how would you make the first row look different to the rest?

Basically I have articles in my database and I want to alter the way the first record displays. I want the lastest (Posted) article to be the focus and the older article just to list, (see F1.com). I need to know how to get the first of my values in the array and get it to display differently but I am not sure how to do this, I can do it...

Java int... array notation

I've seen this before in a method parameter, and it appears to allow an arbitrary number of parameters to be stuffed in an array created at run-time. What's the official name of this language feature? Thanks! public static void trace(View view, RecyclerTraceType type, int... parameters) { RecyclerTrace trace = new RecyclerTrace...

What is the generic alternative of Array?

In C# some collections such as ArrayList and HashTable have generic alternatives which are List<T> and Dictionary<TKey, TValue>. Does Array also have a generic alternative? ...

How to check if an array exists in C#?

Is there any way to check if a array exists or has a value in a specific element? I have this line of code if (rummen[positionX, positionY].Levandesaker[0].alive == true) And it works fine as long as it exists. But what I want to do is if (rummen[positionX, positionY].Levandesaker != null) { if (rummen[positionX, positionY].Leva...

How can I convert a simple XMLList to an Array of Strings without a loop?

How can I convert the following XMLList to an Array of Strings without using a loop? <labels> <label>All</label> <label>your</label> <label>base</label> <label>are</label> <label>belong</label> <label>to</label> <label>us.</label> </labels> I want this result: ["All","your","base","are","belong","to","us."...

C# - Why do you need to instantiate each array element?

I use this type of construct often. response = new LocationResponse (); response.LocationDetails = new LocationDetail[4]; response.LocationDetails[0] = new LocationDetail(); response.LocationDetails[0].site = "ABCDE"; ... The piece I don't fully understand is this piece: response.LocationDetails[0] = new LocationDetail(); Why does e...

How to delete an array in c#?

Im sorry if this is an obvious question but neither google or a search here led me to an answer. Is there a way to remove an array entirely? I want the opposite of int[] array = new int[5] ...

Java native array lengths

Hi, I have a 2D array of doubles in Java which is basically a table of values and I want to find out how many rows it has... It is declared elsewhere (and allocated) like this: double[][] table; then passed to a function... private void doSomething(double[][] table) { } In my function I want to know the length of each dimension w...

jQuery - insert item into array at a specific index

I am looking for a JavaScript array insert method, in the style of: arr.insert(index, item) Preferably in jQuery, but any JavaScript implementation will do at this point because I can't believe the trouble I'm having finding such a basic function! Thanks for your help. ...

Finding prime numbers with the Sieve of Eratosthenes (Originally: Is there a better way to prepare this array?)

Note: Version 2, below, uses the Sieve of Eratosthenes. There are several answers that helped with what I originally asked. I have chosen the Sieve of Eratosthenes method, implemented it, and changed the question title and tags appropriately. Thanks to everyone who helped! Introduction I wrote this fancy little method that generates...

How can I reverse a NSArray in Objective-C?

I need to reverse my NSArray. As an example: [1,2,3,4,5] must become [5,4,3,2,1] What is the best way to achieve this? ...

How to get multidimensional length - of one axis

I have an array such as string[,] SSISVariableNameValue = new string[,] { {"DestinationConfigDB","dest db"}, {"DestinationServer","dest server"}, {"SourceConfigDB","source db"}, {"SourceServer","source server"}, {"SSISConfigFilter","filter"} }; The ....

What is the preferred way to declare a Java array?

Possible Duplicate: Difference between int[] array and int array[] What is the difference between these two declarations of an array of native types in Java? double items[] = new double[10]; double[] items = new double[10]; If they are the same is there any reason to prefer one over the other? ...

Vector Array

I am suppose to create a vector array in C to use in my project. I have not worked with such data structure before, and can't seem to find good information on it. Can you provide a link to information or post the information which describes this data structure in regard to its usage, benefits, and the functions it has. An implementatio...

PHP - pop first element of array instead of last (reveresed array_pop)?

Hi Is there a PHP function that would 'pop' first element of array? array_pop() pops last element, but I'd like to pop the first. ...

Regex on an array?

Hi How do I get the percentage and filesize from this sort of string using regex in PHP? The thing is I get this string using the print_r function like so: while(!feof($handle)) { $progress = fread($handle, 8192); print_r($progress); } The above outputs something like this: [download] 28.8% of 1.51M at 171.30k/s ETA 00...

How do you reindex an array in PHP?

I have the following array, which I would like to reindex so the keys are reversed (ideally starting at 1): Current array (edit: the array actually looks like this): Array ( [2] => Object ( [title] => Section [linked] => 1 ) [1] => Object ( [title] => Sub-Section [linked] => 1 ) [0] =>...