arrays

Pattern Match on a Array Key

Hi. Since I'm finding this site helpful I thought I'd sign up :) I need to get the stock values out of this array: Array ( [stock0] => 1 [stockdate0] => [stock1] => 3 [stockdate1] => apple [stock2] => 2 [ stockdate2] => ) I need to pattern match on this array, where the array key = "stock" + 1 wildcard character. I have tried us...

PHP Array overwriting values but need to add to array

The array: Array ( [0] => Array ( [0] => Service Simulators [1] => Array ( [0] => 1.php [1] => Title 1 ) ) [1] => Array ( [0] => Service Simulators [1] => Array ( ...

NSArray atomfeed and categories

Hi, I have an atomfeed with which is succesfully getting parsed. All the articles are in the root array. But now I also have categories as a tag in the feed. How can I parse the atom xml so that the root array contains the categories and each category filters to an array with the corresponding articles. Thanks, Bing ...

Fastest way to iterate array in PHP

I'm studying for the Zend PHP certification. Not sure the answer to this question. Question: What is the best way to iterate and modify every element of an array using PHP 5? a) You cannot modify an array during iteration b) for($i = 0; $i < count($array); $i++) { /* ... */ } c) foreach($array as $key => &$val) { /* ...

Difference Between int[] and list<int>

What is the difference between: int[] myIntArray and list<int> myIntArray ? In web services I read that I should pick one or the other and not mix the two, why? ...

Unexpected array behavior

The following modify method somehow modifies the whole @x array instead of just simply generating another element to be pushed later. How come? def modify i, s t = @x[-1] t[i] = t[i] + s t end @x = [ [10, 12] ] @x << modify(0, 1) puts @x Edited The following code have done the trick. Still I wonder if its possible to get rid o...

Iterate through a C array

I have an array of structs that I created somewhere in my program. Later, I want to iterate through that, but I don't have the size of the array. How can I iterate through the elements? Or do I need to store the size somewhere? ...

C# equivalent of C++ map<string,double>

I want to keep some totals for different accounts. In C++ I'd use STL like this: map<string,double> accounts; // Add some amounts to some accounts. accounts["Fred"] += 4.56; accounts["George"] += 1.00; accounts["Fred"] += 1.00; cout << "Fred owes me $" << accounts['Fred'] << endl; Now, how would I do the same thing in C# ? ...

Array of objects on stack and heap

Consider the following code: class myarray { int i; public: myarray(int a) : i(a){ } } How can you create an array of objects of myarray on stack and how can you create an array of objects on heap??? ...

ASP.NET which type of collection should I use?

I am writing a class to save searches on my site. I want to have in the class an "Array" of all the parameters that were specified. I tried a NameValueCollection but the problem I ran into is when I have a multi-select (e.g. states) it only stores one of the entries because the key gets taken. I need a collection type that will let me ha...

Dynamic arrays size and dynamic arrays allocators in VC++

hello, guys I'm confused a little while writing own tiny discovering program to clear up how Visual C++ allocates the memory for dynamic arrays. I must note, I have never met technical documents that describe this question on new[]/delete[] operators for any C++ implementation. Initially I thought that new[] and delete[] are something ...

Is there a standard function in C that would return the length of an array?

Is there a standard function in C that would return the length of an array? ...

arrays of structs need advice

I made an array of structs to represent map data that gets drawn; however I didn't double check it till it was too late: when I load in a new map I get either an "out of memory exception" (if i try to make a new array struct first) or I get a screwed up map that would require a lot of recodeing to get it to work right (if i just initiali...

How to return a Ruby array intersection with duplicate elements? (problem with bigrams in Dice Coefficient)

Hi there I'm trying to script Dice's Coefficient, but I'm having a bit of a problem with the array intersection. def bigram(string) string.downcase! bgarray=[] bgstring="%"+string+"#" bgslength = bgstring.length 0.upto(bgslength-2) do |i| bgarray << bgstring[i,2] end return bgarray end def approx_string_match(test...

creating dynamic Arrays Javascript

Hello i want to create a array in java script withing 2 for loops var i; var a; var total = document.getElementsByName('qm[7]') var creativity = document.getElementsByName('qm[0]'); var design = document.getElementsByName('qm[1]'); var text = document.getElementsByName('qm[3]'); var motivation = document.getE...

Putting strings into a 2D chararray in C.

How do I put strings into an 2D char array from (for example) a file? char buffert[10][30]; int i = 0; while(!feof(somefile)) { fscanf(somefile, "%s", temp); buffert[i][] = temp; i++; } This will not do it. ...

array of string with unknown size

How is an array of string where you do not know where the array size in c#.NET? String[] array = new String[]; // this does not work ...

Convert a HashSet<T> to an array in .NET

How do I convert a HashSet<T> to an array in .NET? ...

CSharp what is the difference between Array.Copy and CopyTo ?

Is there any difference between Array.Copy ,CopyTo? Are they Just Overloaded ? ...

A question on how to Get data from plist & how should it be layout.

This is a follow up question on my first queries regarding retrieving data on plist. Right now i have manage to detect users touches made on my view with random image call out (thanks to phytonquick). CGPoint currentTouchLocation = [currentTouch locationInView:self]; Im having trouble now on how to compare the value i got from the use...