arrays

How to create a 'real' JavaScript array in Rhino

Okay, I'm a little stumped. I'm probably missing something blatantly obvious but apparently I just can't see the forest for the trees: I'm trying to call a JavaScript function that expects its parameter to be an array, i.e. it checks if (arg instanceof Array)... Unfortunately, I (or Rhino) just can't seem to create such an array: Con...

Correct syntax for accessing c-style object array through objective-c messaging??

Please see comment: static void drawAnObject() { Form *form = [[Form alloc] init]; int i; [form randomizeCube]; glColor3f(0.0, 0.0, 0.0); for(i = 0; i < MAX_CUBE; i++) { glutWireCube(form->cube[i]->size); //compiler issues hard warning because form->cube is protected!! } } I would rather ...

How to get average distance between array values in PHP?

For the array below, it's ~20 but how to get it programatically? array(12) { [0]=> int(29) [1]=> int(50) [2]=> int(72) [3]=> int(93) [4]=> int(114) [5]=> int(136) [6]=> int(157) [7]=> int(178) [8]=> int(199) [9]=> int(221) [10]=> int(242) [11]=> int(263) } ...

Fast sum of values in a multidimensional array (C#)

With a 1D array, I can use the sum method to get the sum of all the values. int[] array = {6,3,1}; Console.WriteLine(array.Sum()); With a multidimensional array (3D in my case), this can't be done. Obviously I could go all foreach on it, but this seems verbose and I suspect it will perform badly. Is there a way to flatten the array? ...

PHP: Iterating through array?

Hi, What I want, is a function that searches through my array, and returns all the children to a specific node. What is the most appropriate way to do this? Will recursion be necessary in this case? I have previously constructed a few quite complex functions that iterates with or without the help of recursion through multi-dimensiona...

How do I pass an array as a parameter?

This is driving me crazy: I have function void gst_init(int *argc, char **argv[]); in the gstreamer api and I want to call it with some parameters I define, like: int argc = 2; char* argv[2] = {"myvalue1", "myvalue2"}; gst_init(&argc, &argv); This code doesn't compile (I get error C2664): error C2664: 'gst_init' : cannot convert...

Is it safe to pass a vector as an array?

Say I have a function: void someFunc(int *x,int count); which is out of my control, so I can't write it to accept iterators. Is it safe to call it like so (regardless of the specific STL implementation): vector<int> v; /* ... */ someFunc(&v[0],v.size()); Obviously, one counter example is vector<bool>. How about any other type? (as...

How do I dynamically allocate a 2D array of structs?

The dimensions are unknown at compile time, so I'm trying to allocate a 2D array of structs dynamically. The code compiles but I get a bad access when accessing an element. // The struct typedef struct { NSInteger numActors; Actor *a1; Actor *a2; Actor *a3; Actor *a4; Actor *a5; } GridNode; // In interface GridN...

how to query to display column names except an array list

hey guys im looking for to show columns of a table except some. forexample my table name mobile_table has columns like : sony nokia apple LG Sumsung ...and i need to show these columns except Sumsung ,LG $exceptions_arr = "LG,Sumsung" i know how to show column names of a table but not to apply exeption array filter ! $qu...

Ruby/Watir - Formatting print from an array

I'm using Watir to do some automated testing for a website. This particular test I'm pulling an array of sku numbers from an Excel sheet and then randomly selecting one from the array to use as my test. The number is placed into a search field and it pulls back my product. Here's my problem: I'm pulling the data from Excel and I pri...

php array selection

I have the following code and want to manually select an array: <?php $articleQuery = mysql_query("SELECT * FROM articles WHERE topic = 'IT' "); while($article= mysql_fetch_array($articleQuery )){ $aid = $article['id']; $media = $article['media']; $link = $article['link']; } echo $aid[0]; ?> The problem is that its not...

Arrays of data classes in C#

OK, I've been messing around with this for ages and I'm not getting any closer. My current version is as below. The comments are what I think I'm doing. The semantic is basically an index number (like a house number) and a list of attributes in an array. Then create an array 'street'. I want to be able to update the values of all element...

Simple round robin (moving average) array in C#

As a diagnostic, I want to display the number of cycles per second in my app. (Think frames-per-second in a first-person-shooter.) But I don't want to display the most recent value, or the average since launch. What I want to calculate is the mean of the last X values. My question is, I suppose, about the best way to store these values...

vb.net remove a row in two-dimensional array

In vb.net how do you delete a row in a two dimensional array? ...

vector of double[2] error

...

push to array vb.net 2008

the message was variable j is used before it have been assigned value.If in php language, it's not a problem at all. Dim j() As String Dim i As Integer If (i = 1) Then j(0) = "x" Else j(0) = "d" End If ...

Sorting an array of folder names like Windows Explorer (Numerically and Alphabetically) - VB.NET

I'm killing myself and dehydrating trying to get this array to sort. I have an array containing directories generated by; Dim Folders() As String = Directory.GetDirectories(RootPath) I need them to be sorted so they appear like in windows explorer in win7 / vista. -- numerically and alphabetically by folder names. The folder names co...

Google Maps JS API v2 - Simple Multiple Marker Example

I'm fairly new to gmaps and Im using v2 because of the search function that I didnt find in v3. I've got an array of data that I want to loop through and put the markers on the map =) It seems really easy but I cant get it to work with v2 at all... Here is my what my array format and code looks like: function createMarkers(myLatLng,h...

C++ - STL vector question

Hello! Is there any way to make std::vector faster on reserving + resizing? I would like to achieve the performance which would be somewhat equivalent to plain C arrays. See the following code snippets: TEST(test, vector1) { for (int i = 0; i < 50; ++i) { std::vector<int> a; a.reserve(10000000); a.resize(10000000...

make array object in for loop with horizontal view

<?php $xml = simplexml_load_file('http://www.google.com/ig/api?weather=London'); $information = $xml->xpath("/xml_api_reply/weather/forecast_information"); $current = $xml->xpath("/xml_api_reply/weather/current_conditions"); $forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions"); ?> <html> ...