arrays

Java native methods issues with SUN JVM (jdk1.5.0_14) and multi-core CPU’s

We are hosting an application on SUN JVM that handles a lot of XML parsing using Jaxb. The application is parsing the XML fine using JRockit 5 but when using the SUN JVM the JVM spends a majority of it’s time on native methods such as java-lang.System.arraycopy, java.lang.String.intern and java.lang.ClassLoader.getPackage. The CPU load ...

How to fill two-dimensional array using java enhanced loop?

Basically, I am trying this, but this only leaves array filled with zeros. I know how to fill it with normal for loop such as for (int i = 0; i < array.length; i++) but why is my variant is not working? Any help would be appreciated. char[][] array = new char[x][y]; for (char[] row : array) for (char element : row) eleme...

list arrays in Drupal form

Is there a better way to find all form elements in a Drupal form than doing a print_r($form)? This dumps excessive amount of information and it is no obvious what to look for. ...

need some tips on Drupal $form value

I got dpm($form) working. Nice! This is much better way to view data. I am still trying to figure out where stuff is coming from eg: location longitude & latitude. The word 'longitude' is referenced in 20 different places. I thought this was a likely place to isolate text box for this input field. dpm($form['#field_info']['field_store_l...

Understanding ruby array sort

I am having a problem understanding how array.sort{|x,y| block} works exactly,hence how to use it? ruby-doc example: a = [ "d", "a", "e", "c", "b" ] a.sort #=> ["a", "b", "c", "d", "e"] a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] thanks ...

jquery ajax parse xml, split array

Hi, is it possible to get the last value of an string, that looks like this for example: tm="1610612741|Bulls|Chicago|CHI" and save it as a variable? Something like that: var tm = $(this).find('htm').attr('tm'); I only need the "CHI" string. I tried everything, but what i found doesnt work. I get the string and the var from an x...

Need a function in javascript to swap 2 elements in an array

A program to swap two numbers /* /* Function to swap two numbers. Function takes an argument which is an array of two elements. Function returns a new array containing the same two elements as the argument array but in reverse ord...

php mysql query strings array

i am building a string that i check in mysql db. eg: formFields[] is an array - input1 is: string1 array_push(strings, formFields) 1st string and mysql query looks like this: "select * from my table where id in (strings)" formFields[] is an array - input2 is: string1, string2 array_push(strings, formFields) 2nd string and mysql query l...

Zero out array sent as parameter in C++

How do you make all elements = 0 in the array sent as a parameter? int myArrayFunction(int p_myArray[]) { p_myArray[] = {0};//compiler error syntax error: ']' . . } ...

Compress a php array

I need to take an array that looks something like ... array( 11 => "fistVal", 19 => "secondVal", 120=> "thirdVal", 200 =>"fourthVal"); and convert it to... array( 0 => "fistVal", 1 => "secondVal", 2=> "thirdVal", 3 =>"fourthVal"); This is what I came up with - function compressArray($array){ if(count($array){ $counter...

Java - What's the most efficient way of removing a set of elements from an Array[]

I've something like this Object[] myObjects = ...(initialized in some way)... int[] elemToRemove = new int[]{3,4,6,8,...} What's the most efficient way of removing the elements of index position 3,4,6,8... from myObjects ? I'd like to implement an efficient Utility method with a signature like public Object[] removeElements(Object[]...

Cast array in Object variable to type in System.Type variable

I have this function: Public Sub DoStuff(ByVal type as System.Type, ByVal value as Object) End Sub The 'value' argument is always an array of the same type as 'type'. How can I loop through the values of the array? I'd like to be able to do something like this: DoStuff(GetType(Integer), New Integer(){1,2,3}) Public Sub DoStuff(ByV...

How to cast an array to an array with another primitive type

Hi, Can someone complete the code on an easy way? float[] floats = {...}; // create an array // Now I want to create a new array of ints from the arrays floats int[] ints = ????; I know I can simply cast element by element to a new array. But is it possible on an easier way? Thanks ...

Javascript Array.forEach HowTo break?

[1,2,3].forEach(function(el) { if(el === 1) break; }); How can I do this using the new forEach method of JS? ...

Initialize Static Array of Structs in C

I'm implementing a card game in C. There are lots of types of cards and each has a bunch of information, including some actions that will need to be individually scripted associated with it. Given a struct like this (and I'm not certain I have the syntax right for the function pointer) struct CARD { int value; int cost; // ...

How to bind arrays?

Say i have those 3 arrays : Product(milk,candy,chocolate) Colors(white,red,black) Rating(8,7,9) How to create a loop to bind those arrays so i get 3 variables in each loop : $product $color $rating So by example i will output like this: Milk is white and has a rating of 8/10 Candy is red and has a rating of 7/10 Chocolate is black...

Extending a series of nonuniform netcdf data in a numpy array

Hello, I am new to python, apologies if this has been asked already. Using python and numpy, I am trying to gather data across many netcdf files into a single array by iteratively calling append(). Naively, I am trying to do something like this: from numpy import * from pupynere import netcdf_file x = array([]) y = [...some list of ...

How do I create and populate a non-uniformly structured array in PHP?

I am trying to decide on a data structure for an array that has a date for the key and the amount of bandwidth consumed as values. examples Key Consumed Policy October 50 Basic November 75 Basic December 100 Basic Some months, but not all, will have more th...

How to create array items by specify a key that includes hierachy ?

Given original codes as: foreach($option as $name=>$value) $array[$name] = $value; and $name as button[0][text], button[0][value], button[1][text], spider[0][name], ... The result array would be array('button[0][text]' => 'its text', 'button[0][value]' => 'its value', 'button[1][text]' => 'its text', 'spider[0][nam...

VB.NET: I Cant find the index of an array

This is the code for my array (which is working) Public numUsers As Integer Public fNameUsers As String = ("..\..\..\users.txt") Public UserRecords As Usersclass() 'note... this line is in a module ' reader = New System.IO.StreamReader(fNameUsers) numUsers = 0 'Split the array up at each delimiter of "," and add new objects ' ...