arrays

Array Merge (Union)

I have two array I need to merge, and using the Union (|) operator is PAINFULLY slow.. are there any other ways to accomplish an array merge? Also, the arrays are filled with objects, not strings. An Example of the objects within the array #<Article id: 1, xml_document_id: 1, source: "<article><domain>events.waikato.ac</domain...

Whats the best way to sort this array in php?

I cant come up with any sane solution for this problem without resorting to ridiculous combinations of custom functions. Maybe you can provide some fresh thought on this. I have the follow (simplified) array Array ( [0] => Array ( [vid_id] => 420037 [vid_rating] => 2.93827 [vid_quality] =...

How to merge two arrays of undefined type in C# using .NET 1.1

I'm trying to create a utility method that will accept two arrays as parameters, merge them together, and return the resulting array. Discarding duplicates. Ideally, the parameters would accept any array type, such as int[] or string[]. I'm using C# .NET 1.1, and therefore do not have access to Generics or Array.Resize(). Is there a b...

How do I search within an array of hashes by hash values in ruby?

Hi, I have an array of hashes, @fathers. a_father = { "father" => "Bob", "age" => 40 } @fathers << a_father a_father = { "father" => "David", "age" => 32 } @fathers << a_father a_father = { "father" => "Batman", "age" => 50 } @fathers << a_father How can I search this array and return an array of hashes for which a block returns...

Increasing a classes array size of a deserialized xml file

I have an XML file that I deserialize into a class object. This class contains a number of other classes, some of which are arrays. I would like to increase the array size of some of the objects. How can I do this? In the following example, the MyData object has an array size of 5 but the MyArrayClass say only has an array size of 1....

java array problem?

i was finding out highest prime factor which divides num, as shown in program, there's a issue with array and arr[j] = i; j++; Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at primenum.main(primenum.java:13) //to find highest prime factor public class primenum { public static void main(String[] args)...

Concatenate values of n arrays in php

I have an unknown number of arrays, each containing an unknown number of words. I want to concatenate the values from each list so that all possible variations of the words are stored to a final array. For example, if array 1 contains: dog cat and array 2 contains: food tooth and array 3 contains: car bike I'd like the output t...

jquery, array , html , append

Hi, I want to take "div" s and and this html in "li" . This is my HTML code: <ul class="NewContent"> </ul> <div class="test"> <span>Text1</span> </div> <div class="test"> <span>Text2</span> </div> and jquery (not sure if it is ok started): <script type="text/javascrip...

How do I copy an array using a reference in Perl?

If I do the following, it works fine: print $ref->{element}->[0]->{data}; I would like to see how many references are in the array so that I can loop through them, but I am having a hard time doing that. Here is the code I have tried, but it doesn't work: my @array = @$ref->{element}; foreach(@array) { print $_->{data}; } I ...

Array boundaries and indexes

I had an earlier post link textwhere someone said I had my pointer initialized to the wrong element which I don't quite see why, other than they are right and it works with their correction. So here is the basic problem: If I declare an array from 0 to 30 with #define ENDPOINT 15 int record[2 * ENDPOINT + 1]; // and want a pointer to ...

array of array sort_by with nil elements (ruby)

I have code that sorts the way I want. By multiple fields. Cool. But now I realized that sometimes the elements could be nil. Q1: Any idea how to manage to get nil values at the top of the search? And get rid of this error message :in "<=>": undefined method "<=>" for nil:NilClass (NoMethodError) Q2: in the code below I sort by 3 elem...

C++ "dynamic" arrays

I've got some problems/misunderstandings with arrays in C++. int myArray[30]; myArray[1]=2; myArray[2]=4; This is spitting out a lot of compiler errors. I don't think it is necessary to include them here as this is an easy question for everybody with experience in C(++) I guess Why doesn't this work? Is there a way to create a "dyna...

String in between an array?

ok so I have an array with an unknown array amount. so like it can be $array[0] = "a" $array[1] = "b" $array[2] = "c" and what I want is the possibility to make an extra array in between each one, so like $array[0] = "a" $array[1] = "1" $array[2] = "b" $array[3] = "1" $array[4] = "c" $array[5] = "1" ...

Interpretation of int (*a)[3]

When working with arrays and pointers in C, one quickly discovers that they are by no means equivalent although it might seem so at a first glance. I know about the differences in L-values and R-values. Still, recently I tried to find out the type of a pointer that I could use in conjunction with a two-dimensional array, i.e. int foo[2]...

Delphi - The application failed to initialize properly

I have in Delphi application declared tables: x,y,z,r:array [1..10000000] of double; t1,t2,t3,t4:array [1..10000000] of integer; Before everything was ok but now I get in some pcs error (in most pc:s error does not come) : "The application failed to initialize properly (0xc0000005)" If I change tables smaller: x,y,z,r:array [1....

Help with looping Pictures

Hi guys my code for collision detection is as follows i need it to loop through 55 pictures on the main form //aliens are named alien1, alien2 ect //image2 is the collison object ( the bullet) CODE IS TURBO DELPHI procedure TForm1.TimeralienshotTimer(Sender: TObject) var ax2 : integer; bx2 : integer; ay2 : integer; by2 : integ...

send array to function in php

Here is the code : function dosomething () { ... do something with the array... like print value ! } $ar = array(1,2,3); dosomething ($ar); That piece of code work fine... What i try to do is to pass the array DIRECTLY to the function i have try this, non work... HELP ! dosomething ([12,32,56]); dosomething ({12,45,87}); dosomet...

javascript replace

hello, i want to replace month name by number in array, but my script doesnt work. for(i=0; i<a.length; i++) { arr = arr.replace(/Jan/g, "01"); } Can somebody help me please? ...

How to get a value based on another value from a object/array in php

Hi there. My first question here, after enjoying lots og other peoples questions and answers. Thanks for that :) Im trying to work with vimeo's api, and im getting a response I can't figure out to use as I intend. I think its simple for some of you guys, but can't wrap my head around it. I got a bunch of video id's that I need to get t...

Horizontal Vs Vertical browsing of array

Lets consider two almost identical codes: First for (int k=0;k<1000;k++) { for (int i=0;i<600;i++) { for (int j=0;j<600;j++) { tab[i][j] = i *j; } } } Second for (int k=0;k<1000;k++) { for (int i=0;i<600;i++) { for (int j=0;j<600;j++) { t...