arrays

Adding elements to an array?

here i am trying to add elements to the array. the elements i am trying to add are text fields, so im basically trying to store persons contact details within the array list? any help would be greatful public void addContact() { ArrayList<String> details = new ArrayList<String>(); { details.get(txtname(0)); deta...

Combine pairs to groups [PHP / Arrays]

I have pairs of items in an PHP array. Example: <?php $elements = array( 'tiger'=>'lion', 'car'=>'bike', 'lion'=>'zoo', 'truck'=>'plane' ); ?> Now I want to combine these items so that all items which are connected in any way go to one group. Continuation of the example above: <?php $groups = array( 0=>array('tiger', 'lion', 'zo...

int array to string

In C#, I have an array of ints, containing digits only. I want to convert this array to string. Array example: int[] arr = {0,1,2,3,0,1}; How can I convert this to a string formatted as: "012301"? ...

Declaring arrays similar to C style (C++)

In C a programmer can declare an array like so: unsigned char Fonts[2][8] { [1] = {0, 31, 0, 31, 0, 31, 0, 31} }; And element [0] is likely random bits. Is there a similar way in C++? ...

Optimized method for calculating cosine distance in Python

I wrote a method to calculate the cosine distance between two arrays: def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 result = 1 - numerator / (sqrt(den...

What may cause losing object at the other end of a pointer in c++?

EDIT: I have found the error: I did not initialize an array with a size. question can be closed. I have a class V, and another class N. An object of N will have an array of pointers to objects of class V (say V **vList). So, N has a function like V **getList(); Now in some function of other classes or simply a driver function, if I ...

How to get POST data as array with C#

I'm developing an ASP.Net handler with C# that receives an array of data posted from an external Flash program. How can I use the data as array? It seems the HTTP Context used in ASP.Net automatically html-decodes the post data so that it comes out as a simple string. The separator in this case is comma (could be it's always a comma, nev...

Bash: How do I truncate an array?

Hello. I'd like to change the value of an array and would appreciate any help. I got an array like this: users=(root isometric akau) (This is actually a list of current users) that I'd like to be able to test if the user exists and if they do not, then to remove the person from the array. I've tried experiment with this by putting ...

list? dictionary? array?

hi all i'm trying to come up with a very simple way to store a boolean value for each tabpage in a tabcontrol. each page has a textbox, and i would like to store a bool foreach page so if tabpage 1 has been saved, then bool1 is set to true, else false, and so on. then when they go to close the program it will go over all the tabpages a...

Set ItemsSource of a ComboBox to an Array of Integers?

Set ItemsSource of a ComboBox to an Array of Integers? ...

PHP: get all method names from an object with name "bla_"

I have an object and want a method that returns how much method this Object have that start with "bla_". I found get_class_methods() wich returns all method names, but I only want names which starts with "bla_" ...

What is faster or preferred: IEnumerable<>.ToArray() or .ToList()?

I do next: void Foobar(string[] arr, Dictionary<string, string[]>) { var t = arr.Intersect(dic.Keys).ToList(); // .or ToArray() ? foreach(var item in t) { .. } var j = t.Count; // also I need this } which method is preferred? I could go without any but I need to know the size and I don't want to call IEnuramble....

How to merge this two specific arrays in PHP?

I have this array: $array['apples'][0]['name'] = 'Some apple'; $array['apples'][0]['price'] = 44; $array['oranges'][0]['name'] = 'Some orange'; $array['oranges'][0]['price'] = 10; How can I merge the two arrays so i get this: $array[0]['name'] = 'Some apple'; $array[0]['price'] = 44; $array[1]['name'] = 'Some orange'; $array[1]['pri...

How to create and manage several datasets

What is the best way for me to have several datasets ? i've thought about creating a routine for creating datasets with a number in their names, each one with the desired data, but that's not very intelligent (although might work) i'd like to create what would be like an "ARRAY OF DATASETS" vb: <whatever> = ds(1).<whatever> <whatever>...

best method to manipulate array keys in PHP

I have an associative array. I need to add ':' to the start of all the keys. What would be the fastest/simplest way of doing this? And what would be the most efficient way to do this? ...

Convert NSArray to NSString objective-c

Hello, I am wondering how to convert an NSArray example: ( [43,545,@"Test"] ) to a string in objective-c. An applescript example might be: set the_array to {43,"Testing", 474343} set the_array to the_array as string ...

C++ -- Pointers to Arrays -- Arrays of Pointers

Hello, I notice this has caused confusion for several people, but after reading a couple of posts on here and the cplusplus tutorial my brain is still scrambled. Suppose I have the following variables in a header file - int numberOfLinePoints; D3DXVECTOR3* line; //confused as to what it is Then in the implementation C++ file I ini...

Dynamically Create Arrays in Ruby

Is there a way to dynamically create arrays in Ruby? For example, let's say I wanted to loop through an array of books as input by a user: books = gets.chomp The user inputs: "The Great Gatsby, Crime and Punishment, Dracula, Fahrenheit 451, Pride and Prejudice, Sense and Sensibility, Slaughterhouse-Five, The Adventures of Huckleberry...

pythonic way to aggregate arrays (numpy or not)

Hi, I would like to make a nice function to aggregate data among an array (it's a numpy record array, but it does not change anything) you have an array of data that you want to aggregate among one axis: for example an array of dtype=[(name, (np.str_,8), (job, (np.str_,8), (income, np.uint32)] and you want to have the mean income per j...

PHP Calculate Balanced Arrays

Ok, I'm not sure if the title is that effective but its the best I could come up with. Basically here is the scenario. I have 11 categories. In each category, I have items, but one category might have 1 item, 1 might have 20. Now i want to separate the 11 categories into 5 stacks or columns. I want each of the stacks to contain an eq...