arrays

undo or reverse argsort(), python

Given an array 'a' I would like to sort the array by columns "sort(a, axis=0)" do some stuff to the array and then undo the sort. By that I don't mean re sort but basically reversing how each element was moved. I assume argsort() is what I need but it is not clear to me how to sort an array with the results of argsort() or more important...

PHP: Array access short-hand?

In Javascript, after executing a function I can immediately get the an element of the array returned by the function, like so: myFunc("birds")[0] //gets element zero returned from "myFunc()" This is much easier and faster than doing this: $myArray = myFunc("birds"); echo $myArray[0]; Does PHP have a similar shorthand to javascript?...

Delete a single array of object

I am not sure if both of these works to delete: p = new int[1]; delete p and delete [] p; If both work, what is the difference between the above two deletes? ...

I-Phone: Trying to check an Array for an item based on a string produced

Hello! I'm writing a program that will concatenate a string based on letters, and then check an array to see if that string exists. If it does, then it will print a line in IB saying so. I've got all the ins-and-outs worked out, save for the fact that the simulator keeps crashing on me! Here's the code: -(IBAction)checkWord:(id)sende...

C++ sort array of char pointers

Can you tell me what's wrong with my method? I ends up putting the same thing everywhre and it's actually not sorting. void sortArrays(){ int i, j; for(i=0; i<counter; i++){ for( j=0; j<i; j++){ if( strcmp(title_arr[i], title_arr[j]) < 0){ char* title_temp = title_arr[i]; ...

delete[] an array of objects

Hello I have allocated and array of Objects Objects *array = new Objects[N]; How should I delete this array? Just delete[] array; or with iterating over the array's elements? for(int i=0;i<N;i++) delete array[i]; delete[]; Thanks UPDATE: I changed loop body as delete &array[i]; to force the code to compile. ...

Referencing an Array with Objects in iPhone SDK

Hello! I was able to deduce my issue: I'm having problem referencing a string with an object within an array. Here's the code: -(IBAction)checkWord:(id)sender { NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObject:@"BIKE"]; NSString *dudeMan = theWord; if([array containsObject:dudeMan]) { NSLog(@"Awesome!"...

Javascript unset array

How do i unset an array in javascript? i just want to empty it - so it has nothing in it keys or anything ...

PostgreSQL JOIN with array type with array elements order, how to implement?

Hello I have two tables in database: CREATE TABLE items( id SERIAL PRIMARy KEY, ... some other fields ); This table contains come data row with unique ID. CREATE TABLE some_choosen_data_in_order( id SERIAL PRIMARy KEY, id_items INTEGER[], ); This table contains array type field. Each row contains values of IDs from table "ite...

Pass-by-Reference Error

I have a hook system setup... which is working on localhost... I put it live and get an error saying "Warning: Call-time pass-by-reference has been deprecated". Now, apparently the work around is to remove all "&" from your function calls, ie foo(&$me) to foo($me) and then in foo's function definition do "function foo(&$me)". However, ...

Trie VS Suffix Tree VS Suffix Array

Hello everyone, Which one is the structure that provides best performance results? Trie, Suffix Tree or Suffix Array? There are other equivalent structures? What are good Java implementations of these structures? Thanks for your answers. EDIT: In this case I want to make string matching between a large dictionary of names and a large...

PHP While Loops from Arrays

I have a table that contains members names and a field with multiple ID numbers. I want to create a query that returns results where any values in the ID fields overlap with any values in the array. For example: lastname: Smith firstname: John id: 101, 103 I have Array #1 with the values 101, 102, 103 I want...

Javascript Array Scope - newbie here

So, I am learning Javascript while playing white Google Calendar APIs and I just can't figure how this piece of code is working this way: var entriesResult = []; var data = new Date(2010,3,22,17,0,0); var callback = function(result) { var entries = result.feed.getEntries(); if (entries.length != 0) { entriesRe...

Item's depth in ArrayCollection

Hi, is it somehow possible to get item's depth in ArrayCollection? ...

jquery parse json multidimensional array

Ok so i have a json array like this {"forum":[{"id":"1","created":"2010-03-19 ","updated":"2010-03-19 ","user_id":"1","vanity":"gamers","displayname":"gamers","private":"0","description":"All things gaming","count_followers":"62","count_members":"0","count_messages":"5","count_badges":"0","top_badges":"","category_id":"5","logo":"gamer...

Object as an array

I need to create class Dog and PurebredDog extending Dog. Problem is that Dog can be at once single object and array of objects (Dogs and PurebreedDogs : Dog pack[]={new Dog(76589,"As","black",18, "Ann","Kowalsky"), new PurebreedDog(45321,"Labrador","Elf","black",25, "Angus","Ma...

javascript trying to get 3rd nested array.length and value

I have a generated nested Array which I store some data. How can i get the 3rd nested array (in this case the array starting with "yellow") the array looks like this (this is a dynamically generated array): [ ["Large", ["yellow", "green", "Blue"], ["$55.00", "$55.00", "$55.00"] ] ["Medium", ["yellow"...

Generic arrays of parametrized ArrayLists in java?

I am new to Java, so I am not aware of the nitty gritties. Why can't I create generic array of parametrized ArrayList? Instead I have to write, ArrayList<String>[] alist = new ArrayList[10]; or I have to create List of ArrayLists. Aren't arrays supposed to be more efficient than ArrayLists? Then why doesn't Java allow it? Also, wha...

Arrays in php, Compare 2 arrays and keep duplicate values

The following is 2 different definitions of the problem: How can I process 2 arrays so that I can keep the data of duplicate array[key] values. I have arrays A and B. I want to create array C with the children that their id/key values exist in both A and B arrays. Thank you ...

Array.BinarySearch where a certain condition is met

I have an array of a certain type. Now I want to find an entry where a certain condition is met. What is the preferred way to do this with the restriction that I don't want to create a temporary object to find, but instead I only want to give a search condition. MyClass[] myArray; // fill and sort array.. MyClass item = Array.BinaryS...