arrays

How do I programatically pull lists/arrays of (itunes urls to) apps in the iphone app store?

I'd like to know how to pragmatically pull lists of apps from the iphone app store. I'd code this in python (via the google app engine) or in an iphone app. My goal would be to select maybe 5 of them and present them to the user. (for instance a top 5 kind of thing, or advanced filtering or queries) ...

access time for small array vs small struct in c#

Hello, I need to process about 500,000 data points each consisting of 4 decimals. I'd like to use and array of structs to do this. Would this be much slower than using an array of arrays? It seems that memory won't be an issue, but speed will - it needs to be fast. Quick code sample of two options: Option 1: public struct Struct...

How much does it matter if I create a NSMutableArray with capacity=3 instead of capacity=50?

I wonder if this affects performance or memory consumption a lot. I need an NSMutableArray, and at the beginning I can only guess how many objects will be added. About 3 to 5 maybe. So I create it like this: NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:3]; What happens here exactly, when creating it with a capacity o...

Storing items in array by date in PHP

Hi, I am working on a php program that needs to store many "Event" objects in an array. Each event has a "due" date, and I need to be able to easily get these events by that day. There may be more than one event on any given day. I thought about using a MySQL-style date as the key, like $array["year-month-day"], but it's messy. I also ...

Convert a pointer to an array in C++

Hi, The CreateFileMapping function returns a pointer to a memory mapped file, and I want to treat that memory mapping as an array. Here's what I basically want to do: char Array[] = (char*) CreateFileMapping(...); Except apparently I can't simply wave my arms and declare that a pointer is now an array. Do you guys have any idea how...

Passing Argument To Method that Requires "ref System.Array"

I'm using a third party library. One of the methods requires passing an array via ref that will be populated with some info. Here's the definition for the method: int GetPositionList(ref Array arrayPos) How do I construct arrayPos so that this method will work? In the library's not so complete documentation it defines the method as...

Manipulating the Split Function for two arrays

Hello all, I had a question regarding the split function used in Visual Basic. As of now I have written a function that brings in a string value. The string value returned will probably look like this "List1;List2; Field1,Field2". My goal is to use the split function for this string to put all the lists in one array and to put the field...

Should I combine multiple php arrays or not?

I have the following arrays below in PHP that I store a user_id number in to keep track of moderator/admins on my site, then in a page I can just use in_array() to determine if a user should have moderator privileges, I figure this saves some mysql queries by using an array instead. I am wondering, would there be any performance gain ...

newbie: C++ question about initialization lists

Hi all, Let's say I have an array of objects declared in my header. The size of the array could be very large. In my source file, I create the constructor for my class and I'd like to initialize all the objects in my array. If these objects are not being constructed with a zero-parameter constructor, I am told these need to be put in...

How does Fast Enumeration (looping) work in Objective-C? (ie: for (NSString *aString in aDictionary)...)

I'm working on implementing a customized searchBar for a fairly complex table and have come across this code pattern AGAIN. This is a sample from the Beginning iPhone Development book: - (void)handleSearchForTerm:(NSString *)searchTerm { NSMutableArray *sectionsToRemove = [[NSMutableArray alloc] init]; [self resetSearch]; for (NSStrin...

Pythonic way of iterating over 3D array

I have a 3D array in Python and I need to iterate over all the cubes in the array. That is, for all (x,y,z) in the array's dimensions I need to access the cube: array[(x + 0, y + 0, z + 0)] array[(x + 1, y + 0, z + 0)] array[(x + 0, y + 1, z + 0)] array[(x + 1, y + 1, z + 0)] array[(x + 0, y + 0, z + 1)] array[(x + 1, y + 0, z + 1)] ar...

Converting a Javascript array to a function arguments list

Is it possible to convert an array into a function argument sequence? Example: run({ "render": [ 10, 20, 200, 200 ] }); function run(calls) { var app = .... // app is retrieved from storage for (func in calls) { // What should happen in the next line? var args = ....(calls[func]); app[func](args); // This is equivalent...

javascript Replace number output from array with an image.

Hello all, I have a code wich I´d like to alter to output a image instead of a number The image should only be displayed for the so called pick output. There is a structure in the images I'd like to use, so if somebody could be so nice to have 1 or 2 explained, I can do the other 43 :) Example, here is an working example of the code t...

PHP function to reorder an array

Here is a sample array of all external JS files from paypal.com: Array ( [src] => Array ( [1] => https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/lib/min/global.js [2] => https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/tns/mid.js [8] => https://www.paypalobjects.com/WEBSCR-590...

PHP Function to get difference element from both arrays

Here's the situations: I have 2 arrays, eg: $a=array('a','b','c','d'); $b=array('1','b','c','e'); I want to produce 2 arrays with result: $c=array('a','d');//only element appeared on $a $d=array('1','e');//only element appeared on $b Do you have a clever solution? ...

How can I turn my Perl array to XML?

How can I take a Perl array like this @categories = ( ["Technology", "Gadgets"], ["TV &amp; Film"] ); and generate this XML snippet? <itunes:category text="Technology"> <itunes:category text="Gadgets"/> </itunes:category> <itunes:category text="TV &amp; Film"/> I can change the array if there's an easier way to get to the same ...

PHP count amount in array with a given value

Say I have an array like this: $array = array('', '', 'other', '', 'other'); How can I count the number with a given value (in the example blank)? And do it efficiently? (for about a dozen arrays with hundreds of elements each) This example times out (over 30 sec): function without($array) { $counter = 0; for($i = 0, $e = co...

K-means clustering: What's wrong? (PHP)

Hello! I was looking for a way to calculate dynamic market values in a soccer manager game. I asked this question here and got a very good answer from Alceu Costa. I tried to code this algorithm (90 elements, 5 clustes) but it doesn't work correctly: In the first iteration, a high percentage of the elements changes its cluster. From ...

How to Flatten a Multidimensional Array?

Is it possible, in PHP, to flatten a (bi/multi)dimensional array without using recursion or references? I'm only interested in the values so the keys can be ignored, I'm thinking in the lines of array_map() and array_values(). ...

How do I create an array of hashes and loop through them in Perl?

I'm trying to create an array of hashes, but I'm having trouble looping through the array. I have tried this code, but it does not work: for ($i = 0; $i<@pattern; $i++){ while(($k, $v)= each $pattern[$i]){ debug(" $k: $v"); } } ...