arrays

Converting an ArrayList into a 2D Array

In Java how do you convert a ArrayList into a two dimensional array Object[][]? From comments: I will describe you the problem with more details: an XML file includes a list of contacts (e.g. name, address...). The only way I can obtain this information is through an ArrayList, which will be given to me. As I need to store the content...

how to unwrap an array in php

i have this array here: Array ( [0] => Array ( [presentation] => Präsentationen ) [1] => Array ( [news] => Aktuelle Meldungen [devplan] => Förderprogramme [salesdoc] => Vertriebsunterlagen ) [2] => Array ( [user/settings] => Mein Account ) [3] => Array ...

how do i sort the following array/stdclass object in php?!

how do is sort this object by 'pos' in php? Array ( [0] => stdClass Object ( [str] => Mondays [pos] => 170 ) [1] => stdClass Object ( [str] => Tuesdays [pos] => 299 ) [2] => stdClass Object ( [str] => Wednesdays [pos] => 355 ) [3] => stdClass Object ( [str] => Thursdays [pos] => 469 ) [4] => stdClass Object ( [str] => Fridays [pos] =>...

How to use array value for case switching (not array number)

How do you use the VALUE of an array number as opposed to what number in the array it is for determining case? In my code: for (int x = 0; x < 3; x++) { switch (position[x]) { case 0: label1.Text = people[x]; break; case 1: ...

How to get the last item of an array and delete it from the array in JavaScript?

var arr = [1,2,3,4]; I need to get the last one and then delete it from an array called arr: var arr = [1,2,3] ...

Changing an array to list in TFS Reports

Creating a report in Team Foundation Server(TFS) and my parameter is set as an array and I want to be able to display this array. I want to be able to switch the array to a list and then be able to show what is selected out of the list by the parameter the user selects. Can someone help please?? :) ...

How to combine 2 associative arrays in php such that we do not overwrite any duplicate entries in all cases ?

I have two associative array which have many content same and so I want to combine those two arrays in such a way that if I have a in array 1 and a in array 2 than in array 3 I should have entries for both a's and not 1. I have tried using array_merge but it would overwrite entries in 1st array if there are any duplicates in 2nd array, ...

Segmentation fault depending on string length?

I am writing a program that will read lines from an infile using getline into strings, convert the strings to c-strings containing the first m nonwhitespace characters of the string, then concatenate the c-strings into a single char array. A sample file might look something like this: 5 //number of rows and columns in a grid 2 //...

Formatting MySQL Query Data Into Custom Array

I have the following data being returned from my database query: +---------------+-----------+------------------+--------------+-------+ | district_name | school_id | school_name | section | score | +---------------+-----------+------------------+--------------+-------+ | My ISD | 11 | My First School | English...

In Ruby, what is the cleanest way of obtaining the index of the largest value in an array?

If a is the array, I want a.index(a.max), but something more Ruby-like. It should be obvious, but I'm having trouble finding the answer at so and elsewhere. Obviously, I am new to Ruby. Cary ...

Setting an Excel Range with an Array using Python and comtypes?

Using comtypes to drive Python, it seems some magic is happening behind the scenes that is not converting tuples and lists to VARIANT types: # RANGE(“C14:D21”) has values # Setting the Value on the Range with a Variant should work, but # list or tuple is not getting converted properly it seems >>>from comtypes.client import CreateObjec...

Java: getting a value from an array from a defined location

I have an array of numbers and would like to retrieve one of the values from location "index". I've looked at the Java documentation http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Array.html but my code still isn't compiling. here is my method: public class ConvexPolygon implements Shape { java.awt.Point[] vertices; ...

Map a 2D array onto a 1D array C

I want to represent a 2D array with a 1D array. A function will pass the two indicies (x,y) and the value to store. These two indicies would represent a single element of a 1D array, and set it accordingly. I know the 1D array needs to be (arrayWidth *arrayHeight) in size, but I don't know how to set each element. For example if I passed...

How can i delete something out of an array?

My problem is that i have to delete something out of an array. I found out how to delete something out of a listbox. But the problem is that the listbox is filled by an array. So if I don't delete the value (I deleted out of the listbox) out of the array. The value keeps coming back when you add a new item. BTW: I am new to php and javas...

Sorting multi-dimentional array by more than one field.

Hi. I have the following data: Array ( [0] => Array ( [filename] => def [filesize] => 4096 [filemtime] => 1264683091 [is_dir] => 1 [is_file] => ) [1] => Array ( [filename] => abc [filesize] => 4096 [filemtime] => 1264683091 [is_dir] => 1 ...

How to remove a line and column in a two dimension array?

I have an int array with to dimentions: int[,] intArray2D = new int[3,3]; I would like to have two methods such as: int[,] removeLine(int[,] array, int arrayColumnsCount, int lineToRemove){...} int[,] removeColumn(int[,] array, int arrayColumnsCount, int columnToRemove){...} So, having the array: 1 2 3 4 5 6 7 8 9 Calling the re...

What would be the best way to add two associative arrays such that duplicate values are not over written : `+` or `array_merge` ?

What is the best way to add two associative arrays such that duplicate values are not over written : + or array_ merge ? I was pretty sure that using + operator I can add two associative arrays such that duplicate values are not over written but this Answer is saying something different and so am not sure if it is really true. I would ...

array key initial value

i want to set my array key initial value to a certain number. here is what i have: $tickets=array(); array_push($tickets,"10","20","TBD") for($i=3; $i<20; $i++) i want my array initial value to start at 3 not 0. any ideas ...

Delete mth element from an array

Given an array of size n, I need to a write a function which deletes every mth element in the array till only one element exists in the array and return that value. Can somebody just give me the hints? ...

XamlParseException when databinding a ComboBox to a statically-defined array in XAML

I've been trying to solve this problem for over an hour now, and can't figure it out. Hopefully someone can see what I'm doing wrong. I have two separate projects, both of which populate a combobox with an array of Doubles in the UserControl.Resources section, then databind to it in the GUI. What I'm doing is essentially just this, wh...