arrays

How can I store a Perl array in an array?

I want to be able to place an array into an array. For example, I may have an array like this: my @array1 = ("element 1","element 2","element 3"); Then I have another array my $array_ref = ["this will", "go between", "element 1 and 2"]; I want to place $array_ref into the first so that the first array looks like this: ("element 1"...

Any way to detect whether the pointer points to array?

Hi, everyone! Is there any way to detect, whether the pointer points to array in C++? My problem is that I want to implement a class, that becomes the owner of the array. My class is initialized with the pointer and I would like to know, whether the pointer is really an array pointer. Here is the simplified code: class ArrayOwner { pub...

Define a double array without a fixed size ?

Hello i have a problem with c# Arrays. I need a array to store some data in there... My Code is that double[] ATmittelMin; ATmittelMin[zaehlMittel] = Gradient(x, xATmax, y, yATmax); But the compiler says: not defined var How can i define a double array without a fixed size ? Thanks a lot! ...

VB.NET syntax for arrays of objects

What is the VB.NET syntax for declaring the size of an array of objects at runtime? To get an idea of what I mean, here is the code so far: Private PipeServerThread As Thread() Public Sub StartPipeServer(NumberOfThreads As Integer) ' ??? equivalent of C# ' ??? PipeServerThread = new Thread[numberOfThreads]; ' ??? goes he...

Read file into array

I have a file of words/phrases separated by newlines. I need to get the file and read each word/phrase into the array. I have this so far: NSFileHandle *wordsFile = [NSFileHandle fileHandleForReadingAtPath:[[NSBundle mainBundle] pathForResource:@"WordList" ofType:nil]]; NSData *words = [w...

Java- checking the value in a MultiDimensional Array

Hello all, I am working on an assignment to create a tictactoe game using a multidimensional array, a separate class with methods to be invoked by the main class. The array is 3 X 3 and is initialized to zero. When player 1 chooses a location on the board a 1 is put in that specific index. Then the prompt allows player 2 to make thei...

What's The Best Way To Sync 2 Data Structures in PHP?

So I am trying to Sync a bunch of Videos I've retrieved from a particular user from Youtube to a database table of Video Ids. This is because YouTube does not allow the adding of meta information to a video. Hence I've created a video table on my server and would like to sync up videoids. i.e. php/mysql app <-> youtube The datastructu...

Randomizing -and remembering that randomisation- multiple choice questions in php.

Problem: I'm trying to code a multiple choice quiz for my fellow students -and primarily to aid my own learning- and so I'm creating a multiple choice web-based quiz using PHP (5.2.08) and MySQL (5.0.32) The questions table is: +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key |...

Get first key in a [possibly] associative array?

What's the best way to determine the first key in a possibly associative array? My first thought it to just foreach the array and then immediately breaking it, like this: foreach ($an_array as $key => $val) break; Thus having $key contain the first key, but this seems inefficient. Does anyone have a better solution? ...

Moving around key order in a multi-dimensional array

How can I "reorder" the keys in a multi-array? For example, I have: $arr["abc"][0] = "val1"; $arr["abc"][1] = "val2"; $arr["abc"][2] = "val3"; $arr["xyz"][0] = "val4"; $arr["xyz"][1] = "val5"; $arr["xyz"][2] = "val6"; And I want it to be: $arr[0]["abc"] = "val1"; $arr[0]["xyz"] = "val4"; $arr[1]["abc"] = "val2"; $arr[1]["xyz"] = "val...

combine two arrays

Possible Duplicate: Elegant way to merge two arrays as key value pairs in PHP? I have two arrays: Array ( [0] => A [1] => B [2] => C [3] => D [4] => E ) Array ( [0] => APPLE [1] => BANANNA [2] => CRANBERRY [3] => DURIAN [4] => EGGPLANT ) I want to combine them so that first value of th...

I can not access Count property of the array but through casting to ICollection !!

int[] arr = new int[5]; Console.WriteLine(arr.Count.ToString());//Compiler Error Console.WriteLine(((ICollection)arr).Count.ToString());//works print 5 Console.WriteLine(arr.Length.ToString());//print 5 Do you have an explanation for that? ...

String to Array and Back : PHP

In PHP I have a string, how do I convert it to an array? After manipulating that array, how do I again make it into a string? Do strings in PHP behave the same way as in Java? is there a dupe for this? thanks in advance ...

Java Iterate Bits in Byte Array

How can i iterate bits in a byte array? ...

Finding Nth item of unsorted list without sorting the list

Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array... ...

Initializing 2D int array

Hello. I got this code from a c++ book, and I cannot figure out how the initialization works. From what I can see, there is an outer for loop cycling trough the rows, and the inner loop cycling trough the column. But its is the assignment of the values into the array that I do not understand. #include <iostream> using namespace std; i...

Flatten an array of hashes in ruby

I have some simple code that looks like this: fruit.each do |c| c.each do |key, value| puts value end end This works fine, but it feels un-ruby like. My goal is to take this array: [{"fruit_id"=>"1"}, {"fruit_id"=>"2"}, {"fruit_id"=>"3"}] And convert it to this: [ "1", "2", "3" ] Thoughts? ...

Delphi: TImage.Create causes Access violation

I apologize in advance for a newbie question, but why do I get "Access violation" error with the code below (on the "Create(SelectorForm);" line)? I tried using the main form as the owner, but it didn't make any difference. var SelectorForm: TSelectorForm; ArrayOfImages: Array [1..10] of TImage; implementation procedure TSelectorF...

What is the usage of array of zero length?

for example we can construct such a this array like==> new elementType[0]; I have read this such a construct but I didn't get the whole such the usage of these arrays!!! :( ...

Customizing Sort Order of C# Arrays

Hey there. This has been bugging me for some time now. I've tried several approaches and none have worked properly. I'm writing and IRC client and am trying to sort out the list of usernames (which needs to be sorted by a users' access level in the current channel). This is easy enough. Trouble is, this list needs to added to whenever...