arrays

How can I find unique rows in a matrix, with no element order within each row?

Hi, I have an array comprising n rows and 4 colums. Each of the four entries on the row is an integer, i.e., X = [ 111 112 432 2 6 9 115 111 112 432 111 2 ]; Each row represents the vertices of a tetrahedron. These vertices have no directionality thus, in the case above, the tetrahedra represented b...

O* p = new O[5]; What does p point to?

To the first O of the array? ...

AS3 Array question

var firstarray:Array = new Array(); function traceArray(arr:Array){ for(var i:int = 0; i < arr.length; ++i) { trace(firstarray[i].matrix); } } for (var i:int = 0; i < 10; ++i) { firstarray.push({ matrix:[1,0,0,1], prod:i}); } var secondarray:Array = new Array(); secondarray = firstarray; secondarra...

string.Format fails at runtime with array of integers

Consider string.Format() whose parameters are a string and, among others in the overload list, an object[] or many objects. This statement succeeds: string foo = string.Format("{0} {1}", 5, 6); as does this: object[] myObjs = new object[] {8,9}; string baz = string.Format("{0} and {1}", myObjs; as does an array of strings: string...

How do I format the output array in CakePHP

Let's say I have an index action where I want to get a list of projects: $this->Project->find('all', array('order' => 'Project.modified DESC', 'conditions' => array('Project.user_id' => 1))); It works well and returns the following array: Array ( [0] => Array ( [Project] => Array ( [id] => 2 [title] => test project ) ) [1] => Array (...

Putting method calls into an ArrayList?

Hey everyone, I was adding a loading bar feature to my program in Java and I was wondering if I could set a list of processes that need to be done, so that it knows how many processes it needs to complete. For example, saving them as strings? ArrayList<String> processes = new ArrayList<String>(); processes.add("CSVWriter.createFileOfC...

Change Array keys to numeric in PHP

Hi everyone! This is probably a simple question for you php whizzes out there but I can't seem to find an answer in google! I have a multi-dimensional array which first set of keys are named and I want to change them into numbers like 0, 1, 2.. If it was a normal array I could set $newArray = array_values($multiArr); and it would get ...

References in Perl: Array of Hashes

I want to iterate through a reference to an array of hashes without having to make local copies, but I keep getting Can't use string ("1") as an ARRAY ref while "strict refs" errors. Why? How do I fix it? sub hasGoodCar { my @garage = ( { model => "BMW", year => 1999 ...

How can I use Array#delete while iterating over the array?

I have an array that I want to iterate over and delete some of the elements. This doesn't work: a = [1, 2, 3, 4, 5] a.each do |x| next if x < 3 a.delete x # do something with x end a #=> [1, 2, 4] I want a to be [1, 2]. How can I get around this? ...

[VB.NET/C#] Finding position of an element in a two-dimensional array?

Well simple question here (maybe not a simple answer?) Say I have a two dimensional array [0] [1] [2] [3] [4] [5] [6] [7] [8] Now suppose I want to get the position of the number 6 I know with a one-dimensional array i can use Array.indexOf() but what would my options be with 2-dimensional arrays? Thanks! ...

Month Array in JavaScript Not Pretty

How can i make it nicer? var month = new Array(); month['01']='Jan'; month['02']='Feb'; month['03']='Mar'; etc. Itd be nice to do it like: var months = new Array(['01','Jan'],['02','Feb'],['03','Mar']); For example. anyway like that to simplify it? ...

Convert flat array to the multi-dimentional

I have an array with tree data (by parent id). I want to convert it to multidimensional array. What is the best way to achieve that? Is there any short function for that? Source array: $source = array( '0' => array( 'Menu' => array( 'id' => 45 'name' => 'Home' ...

How to reset array in multiview iphone app

I am trying to have a tableview that leads to another tableview whose list items depend on the first view. I have the database set up properly and my problem is that when I select one item on the first page and go to the second view for the first time it works fine but when I return to the first page and go back to the second view again ...

Tab formatter tool to prepare array data

Is there a tool that can take this: Attack,Decay,Sustain,Release 45,-1,26,55 "VERY LONG TEXT",false,true,true 0,0,1,1 and output it in a tabbed-format like this: Attack, Decay, Sustain, Release 45, -1, 26, 55 "VERY LONG TEXT", false, true, true 0, 0, 1, 1 I need it...

Can I use a variable to specify the size of a struct member array?

I am trying to represent a HD page in a struct. The code below does not work, because page_size is not a constant. int page_size = 4096; struct page { char data[page_size]; /* some methods */ } Since I am building and randomly accessing arrays of pages, it would be nice if I could treat a page as a fixed length struct of size p...

Multi Dimensional arrays in php

Hi, I am new to php (learning since 1 week ). I am learning arrays. while doing it, I found a api which gives out results in the form of a multidimensional array.. and I am unable to echo the values of the array .. Sample response Array ( [query] => Array ( [count] => 1 [created] => 2010-07-16T08:35:38Z...

Arguments in a function prototype

Hi. My question is: when i write a function prototype in C like this: void foo(int *vector); It's the same thing to do: void foo(int vector[MAX_LENGTH]); To the function, is passed always as a pointer? The code it's the same? Thanks in advance. ...

PHP PDO fetch returns a array ?

$GetUid = $dbConnect->prepare("SELECT UID FROM users WHERE username = :username"); $GetUid->execute($RegisterData3); $UserID = $GetUid->fetch(); why does it return array not a string ? var_dump('$UserID') says array 'UID' => string '45' (length=2) 0 => string '45' (length=2) it should be array 'UID' => string '45' (length=2)...

PHP Hourly Calendar, Running through timestamps stored in database.

I have a MySQL table titled 'my_cal' with a column titled 'start_time' for particular events in the calendar. The way items are added to the database, there are no overlapping events. There also may not be an event for a particular day/time either, in this case we leave it blank or put a blank value. My problem lies in the fact that ...

how to take all array elements except last element in C#

I have a string array like this. string[] queries with data more than one string. I want to skip the last string from the element and take the remaining. I have come up with var remStrings = queries.Reverse().Skip(1).Take(queries.Length - 1); Is there a better alternative to this? ...