arrays

Efficient insertion/deletion algorithm for an array

Hi there, I subscribe to a data feed and from that create and maintain a structure using the index values on the INSERT/DELETE messages. I would like to ask the assembled cognoscenti whether they know of any algorithm which can deal with the piecemeal updates in an efficient way - generally batch-updates contain between two and six suc...

Dynamically populate Text Fields in Flash (AS3)

I am trying to figure out how to dynamically populate textfields in Flash. The text in the fields will either say ON or OFF based on the value of bstatus. var bstatus will either have a value of 0 or 1 I have the following textfields listed below. I'm not sure if the syntax is correct, but I was thinking that the text fields would ...

How do I code a simple integer circular buffer in C/C++?

I see a lot of templates and complicated data structures for implementing a circular buffer. How do I code a simple integer circular buffer for 5 numbers? I'm thinking in C is the most straightforward? Thanks. ...

Multi-Dimensional Arrays--> Null Object Pointers

I am trying to develop a C++ application. Part of the Application is meant to create and initiate some properties of an Object and then store the object in a multi-dimensional array. Problem is after Object creation and storing the objects in the array, retrieving the Object values gives me pointers to NULL. Please see code below for ex...

Posting with PHP and Curl, deep array

I'm trying to post via curl, I've been using the same code over and over again with no problem but now I need to be able to use an array for posts (i'm not sure if there's a proper term for that?). I should clarify that it's specifically a file i'm trying to post, but I can't get it working with a string either so I don't think it's too...

Reset the Internal Pointer Value of a PHP Array (ArrayObject)

Consider a simple PHP ArrayObject with two items. $ao = new ArrayObject(); $ao[] = 'a1'; // [0] => a1 $ao[] = 'a2'; // [1] => a2 Then delete the last item and add a new item. $ao->offsetUnset(1); $ao[] = 'a3'; // [2] => a3 I'd very much like to be able to have 'a3' be [1]. How can I reset the internal pointer value before I add...

C#/PHP : Is there an equivalent of PHP's array_map() function in C#?

The title says it all. :) I've been pondering this today, and I have a nagging feeling that this is something simple to implement and I'm just way out of it today, but anyway, here it is. Instead of performing something like // assume that I have a populated string[] myString for (int i = 0; i < myString.Length; i++) { myString[i] ...

Game Development - Array with pointers to array elements

I am currently developing a game for the iPhone/iPod/iPad. To store the board data, which is 12 columns by 8 rows, I have an array that stores pointers to one of the game items, a block. It is declared as follows: BlockData* mBoard[kNumberOfColumns][kNumberOfRows]; I also have another array declared like this: BlockData* mCenterSqu...

problem accessing to a variable in object

Edit: this is part of main function to call the grab function: $video['type'] = $videoProvider; $video['id'] = $videoIds; $video['title'] = $this->grab_title_from_curl($data); I have this little function to parse title from html via curl, it works. private function grab_title_from_curl ($pull){ ...

Reformat a simple PHP array

How do I go about reformatting an object? Array ( [0] => Array ( [user_id] => 5 [first_name] => Ace [last_name] => Black ) [1] => Array ( [user_id] => 6 [first_name] => Gary [last_name] => Surname ) [2] => Array ...

Calling a function within a array

Hello, How do I go about calling a function within a jQuery array to add another array? $('#map').zoommap({ // Width and Height of the Map width: '490px', height: '380px', //Region map: function getMaps(); }); getMaps() should return the following: { id: 'campus', image: '/resour...

Searching for objects in JavaScript arrays

how to search for the property of an object in an array , without using for loops in JavaScript ? If array is a simple one , I can use array.indexOf(value) to get the index but if array is array of objects ? other than looping any other way ? e.g. ar = [{x,y},{p,q},{u,v}] if searched for v , it should return array index as 2. ...

PHP DOM array - cut the first element - better way to do it

Dear friends ! I'm really stucked and don't know how to implement an idea better. So, we have an XML file: I've got an array by function dom_to_array() function dom2array($node) {$result = array(); if($node->nodeType == XML_TEXT_NODE) { $result = $node->nodeValue; } else { if($node->hasAttributes()) { $attribut...

Converting array of objects to array of arrays

Hi, I have a Array of objects which is something like this : SomeObject (Array) [0] (object) id = 1 name = 'one' [1] (object) id = 2 name = 'two' I need it to be An Array of arrays , something like this : someobject (array) [0](array) id = 1 name = 'one' [1](array) id = 2 name = 't...

PHP: problem inserting array inside an array

Hi folks, I have a script that is using the google charts API and the gChart wrapper. I have an array that when dumped looks like this: $values = implode(',', array_values($backup)); var_dump($values); string(12) "8526,567,833" I want to use the array like this: $piChart = new gPieChart(); $piChart->addDataSet(array($values)); I ...

Need help understanding operator overloading in C++

I'm trying to implement a structure which is basically a custom made hash table containing either nothing (NULL) or a pointer to a binary search tree object. Anyway, I'm having trouble figuring out how to do some things, such as setting the hash table, which is an array to NULL, and also memcpy'ing BST objects from one table to another....

How do you initialise an array of const values in D2?

Essentially, I want to be able to do something like this: struct Foo { const(int)[2] ints; this(int x, int y) { ints = [x, y]; } } but this doesn't work. The compiler (DMD 2.048) just complains that ints isn't mutable. How are you supposed to initialise the array? ...

PHP cannot access object in array

in my application i get returned an array of objects and i am trying to access to access the object inside the array like this $array[0]->name but it doesn't work for some reason , i tried to access it like this - $var = $array[0]; $var->name and it shows me this error > Trying to get property of non-object whats going on here ? why i ...

How to save checkbox array in database?

Hi, I have this form: <tr> <td><input type="hidden" name="ledlamps" value="LED lamps">LED lamps:</td> <td><input class="field checkbox" type="checkbox" name="box[]" value="3mm"/><label class="choice">3mm</label></td> <td><input class="field checkbox" type="checkbox" name="box[]" value="5mm"/><label class="choice">5mm</labe...

Find the 2nd largest element in an array with minimum # of comparisom.

For an array of size N, what is the # of comparisons required? ...