arrays

Java: Remove double from string and store in array

Hi folks, I have a string that will be different each time but follow the form of -3.33,-46.53,37.39,26.55,97.11,68.46,-32.46,-5.89,-62.89,-7.9, and i want to remove each number and store as an double in an array. even pseudocode would be great i'm drawing a blank. Cheers ...

Java: Parsing a string to a double

Hi folks, I'm reading a file into an array and trying to take out the numbers and put them as a double in an array of their own. And apparently my middle name must be "Error". From what I can tell the code is ok....at least theres nothing jumping out at me. Here it is in all it's glory. import java.io.BufferedInputStream; import java.io...

Is it possible to convert a PHP function's parameter list to an array?

Suppose I have a function: function my_function($a, $b, $c) { ... } I want to be able to play with my parameter list as if it were an array - as with here, using a fake $parameter_list variable: function my_function($a, $b, $c) { foreach ($parameter_list as $value) { print $value."\n"; } ... } How can I do t...

How can I convert a PHP function's parameter list to an associative array?

I want to convert the arguments to a function into an associative array with keys equal to the parameter variable names, and values equal to the parameter values. PHP: function my_function($a, $b, $c) { // <--- magic goes here to create the $params array var_dump($params['a'] === $a); // Should result in bool(true) var_d...

How would I give the buttons in this image gallery a rollover effect, as well as assign each of them individual labels?

So I am trying to make these "Buttons" in my image gallery have some sort of rollover effect (text change color) , also instead of saying "Linus0", "Linus1", "Linus2", I would like to assign each one its own label. Am I able to do this with an array? Also - what am I doing wrong thats making it think there are six images total? There ar...

Javascript complex array "element reduction" - building an HTML table based on array elements

I have a project that requires the following. Four arrays will be declared in the code as such: var ROW1 = ['module1']; var ROW2 = ['module2', 'module3']; var ROW3 = ['module4', 'module5', 'module6']; var ROW4 = ['module7', 'module8']; Each element of these arrays represents a module in a configurable HTML widget. Based on what eleme...

double[,], int[], bool[] ... matrix,vector manipulation extensions in C#

I need(for rapid prototyping and libraries integration) something like this(extensions for usual arrays) double[] d; d.SetRow(1,{ 1.1 , 2.0 ,3.3}); var r = d.GetRow(1); d = d.AppendRight(new int[]{1,2,3}); ... Does exist such thing anywhere? On may be anybody implemented it so I do not need do i for me myself? ...

Is there a generally accepted way to add meta information to array-elements indicating how to handle them?

I am using an array which contains the results of a database-query, which is later formatted as html (for a webapplication) or as csv (for import in a spreadsheet). I want to attach information to the array-element which has some additional information about how the data of this element can be used. For instance, array-element-data... ...

C# assign values of array to separate variables in one line

Can I assign each value in an array to separate variables in one line in C#? Here's an example in Ruby code of what I want: irb(main):001:0> str1, str2 = ["hey", "now"] => ["hey", "now"] irb(main):002:0> str1 => "hey" irb(main):003:0> str2 => "now" I'm not sure if what I'm wanting is possible in C#. Edit: for those suggesting I jus...

Sorting an array of doubles or CLLocationDistance values on the iPhone

I'm trying to sort a list of CLLocationDistance values by closest distance (ascending order). I first converted the values to NSString objects so that I could use the following sort: NSArray *sortedArray; sortedArray = [distances sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; NSString cannot sort on the numeric value. ...

How to sort javascript object array by element.name

Hi, I am try to write some validation script using javascript and prototype. What I want to do is to loop through all the elements of a form and validate each answer. My code works, BUT the array of DOM elements is unsorted. I would like to sort the elements by their ID. Here is the my code, which works fine if I comment-out elem.s...

Working with time in the iPhone

I have two arrays with time values in them in this format. 00:00:00 which is minutes:seconds:miliseconds. Can someone show me any easy way of adding an subtracting these values? I know I can if I break them down but I am looking for a way to do it without of code. I can get the last values which is what I want to work with like this ...

Most efficient way to grow an array in Java?

Is there a more efficient way to grow a large array than creating a new one and copying over all the values? Like, concatenating it with a new one? What about having fixed-size arrays stored in another array and reallocate / copy that top-level one? Would that leave the actual values in place? I'm aware of ArrayList, but I need a lot o...

How to get the 'diff' between arrays in Java

I am attempting to write some test cases for some classes that involve testing the equality of two dimensional arrays of data. Here is my first stab at it: double[][] expected = { {0, 104, 0}, {145.5, 0, 0}, {83, 0, 0} }; double[][] actual = someObject.getArray(); Now, I see that JUnit does not have an 'array...

seeing if an object exists at index[i] in NSMUtableArray

People I'd like to see if an element at index[i] is not present in a different (or current ) array. So for instance if my array looked somewhat like this [wer, wer4 , wer5 , werp , klo ... Then I would like to see if aExerciseRef.IDE ( which is "sdf" for instance ) does or does not exist at index[i]. I assume I'd have to use some sor...

indexOf syntax for multidimensional arrays?

What is the syntax for indexOf() to go through a multidimensional array? For instance: var x = []; // do something x.push([a,b]); x.indexOf(a) // ?? I want to find 'a' and do something with 'b'. But it does not work... As this method should be iterative itself, I do not presume using any other iteration would be a good thing to do. C...

How can I search for and delete an array element in PHP?

I have a PHP array that looks like this: Array ( [0] => Array ( [start] => DateTime Object ( ) [end] => DateTime Object ( ) [comment] => A comment. ) [1] => Array ( [start] => DateTime Object ( ) [end] => DateTime Object ( ) [comment] => Another comment. ) ) I would like to create a function that...

One way to compare array

Hello all. I'm wondering if my method below of comparing an array of strings (or any simple type really) has any performance repercussions. bool AreValuesEqual(List<string> oldFieldValue, List<string> newFieldValue) { if (oldFieldValue.Count != newFieldValue.Count) return false; var list1 = oldFieldVa...

Getting the min and max values from a PHP array

Is there a built in PHP function that will allow you get the minimum and maximum values from a PHP array? If not, what's the most efficient way of doing this for the general case? ...

Array access optimization

Hi all, Just a quick question really. Say I have a 10x10 array in Java, some of the places in which are not used, and I'm needing to go through all elements as part of a method. Would it be better to: Go through all elements with 2 for loops and check for the nulltype to avoid errors, e.g. for(int y=0;y<10;y++){ for(int x=0;x<10;x...