arrays

Is there a fast way to delete a specific value from an array in Javascript?

I have an array var array = ["google","chrome","os","windows","os"]; I want to delete the value "chrome" from the array without the array becoming a string. Is there a way to do this? ...

Is it possible to do a reduction on an array with openmp?

Does OpenMP natively support reduction of a variable that represents an array? This would work something like the following... float* a = (float*) calloc(4*sizeof(float)); omp_set_num_threads(13); #pragma omp parallel reduction(+:a) for(i=0;i<4;i++){ a[i] += 1; // Thread-local copy of a incremented by something interesting } // a ...

Is there a method to clone an array in jQuery?

This is my code : var a=[1,2,3] b=$.clone(a) alert(b) Doesn't jQuery have a 'clone' method? How can I clone an array using jQuery? ...

php array recursion

Hello. I have an array like this: Array ( [0] => Array ( [id] => 1000 [enroller_id] => 1005) [1] => Array ( [id] => 1005 [enroller_id] =>) [2] => Array ( [id] => 1101 [enroller_id] => 1000 ) [3] => Array ( [id] => 1111 [enroller_id] => 1000 ) ) I want to create hierarchy array like this: Array( [1005] => Array( ...

php get subarray from array by key.

I have the next hierarchy array: Array( [1005] => Array( [1000] => Array( [1101] => ... [1111] => ... ) ) ) In my function I send $Id. And my task to return a array by this Id. For example: getArray(1000) should retu...

Rotate 2D rectangular array in-place

I have an non-square array like this: const int dim1 = 3, dim2 = 4; int array[12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12}; and I need to convert it to: {3,6,9,12, 2,5,8,11, 1,4,7,10} that is, rotate/shuffle it counter-clockwise (or clockwise, the algorithm should be similiar)...

JavaScript - get array element fulfilling a condition

Hi, I'm learning JavaScript using W3C and I didn't find an answer to this question. I'm trying to make some manipulations on array elements which fulfill some condition. Is there a way to do it other than running on the array elements in for loop? Maybe something like (in other languages): foreach (object t in tArray) if (t follows...

JavaScript - How to make an array that contains objects by reference?

Hi, I'm using JavaScript Mapping Library - OpenLayer to create a markers overlay. I want to control the markers dynamically: add new ones and remove existing markers from the layer. the way to add a new marker to the layer is by the command: markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon)); as you can see, t...

Questions regarding Vector Array of Structs

I made a post about this yesterday, but it is a fairly different question. Not sure if I should make a new question or just reply to the old one but here goes. Basically I am setting up my vector array of structs as follows.. class Debugger : public Ogre::SimpleRenderable { struct DebugVertex { Ogre::Vector3 v; ...

Pass array of srtucts as WCF method parameter in HTTP GET

i have a WCF Method that receives array of structs. the struct contains two strings "Key" and "Value": public struct mydata { public String key; public String value; } [ServiceContract] public interface IBasicService { [OperationContract] [WebGet(UriTemplate = "ReceiveStructsOfData?myDataArray={???????? WHAT DO I WRITE...

php array recursive sum

Hello. I have an array like this: Array ( [1000] => Array ( [pv] => 36 ) [1101] => Array ( [1102] => Array ( [pv] => 92 ) [pv] => 38 ) [pv] => 64 ) How I can find the sum of all array elements with key...

Unable to access FOR...IN in Javascript Array

Hi, I want to access the object in [] JSON literal as an array using FOR...IN. But iterating through FOR...IN gives the object x undefined. Please see the code below. var myJSONObject = [ {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}, {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"}, ...

Is there a general way of converting a hash into an two-dimensional array?

The way a hash is structed can always vary, it can be a hash of a hash of an array or whatever. And for every different struct of a hash there needs to be a different implementation of turning it into a two dimensional array. Is there a general way of converting a hash into an array? Such that i could say, for instance, first key become...

How do I push a value onto a Perl hash of arrays?

%TEST ; ... for { sub atest } sub atest { ... push $TEST { TEST1 }[0] = "some value " } How push values into Hash of arrays and dont know anything about index? How do I acheive this? ...

inversion pairs in an array - application

I came across an algorithmic problem to find out the number of inversion pairs in an array in O(nlogn) time. I got the solution to this. But, my question is that what is the real-life application of this problem? Like I want to know some applications where we need to know the inversion pairs. ...

Java array creation

This is just a simple question, and I can't find the answer in the documentation ! String args[] = new String[0]; args[0] = "test"; Is that correct ? Does this creates an array with 1 element or 0 elements ? Thank you, I know, stupid question, but I couldn't find the answer in the Java doc. ...

Delphi: array of Char and TCharArray "Incompatible Types"

I've run across this "Incompatible types" error in the comment below a few times, and never been happy with why this isn't directly supported in Delphi 2007: program Project1; {$APPTYPE CONSOLE} type TCharArray = array of Char; procedure DoArray(Chars: array of Char); begin end; function ReturnTCharArray: TCharArray; var CharArray: T...

Why does my Perl recursive function never end?

I'm trying to write the following recursive function. The problem is that it never ends and I can't understand why: sub do_smth(@first, @second){ my @tmp_first = @first; $tmp = shift(@tmp_first); if (@tmp_first > 0){ do_smth(@tmp_first, @second); } my @tmp_second = @second; $tmp = shift(@tmp_second)...

How to Fix "Not all code paths return a value"?

I have an object array that i'm returning to use the objects in a different method, however for some reason it's saying "not all code paths return a value" Here's the code.... private object[] runTests(string banText, object tabControlName, int runThisTest, string testName) { if (stopTests == false) { v...

Search array keys and return the index of matched key

my array looks like this: [sx1] => Array ( [sx1] => Pain in Hand [sx1L] => Location [sx1O] => Other Treat [sx1T] => Type [sx1R] => Radiation [sx1A] => Aggrivate Ease [sx1D] => Duration [sx1I] => Irit [sx1P] => Previous Hx ...