arrays

How can i declare dynamic String array in java

I am using String Array declare as zoom z[]=new String[422];but this array store value from 0 to 32,so i got null pointer exception after looping value 32,how to solve this problem in java,How can i declare dynamic array in java ...

NSArray creation with variable argument lists in Objective-C

myArray = [NSArray arrayWithObjects:aDate, aValue, aString, nil]; This array convenience method takes a comma-separated list of objects ending with nil. What is the purpose of the nil? ...

Is it possible in PHP for an array to reference itself within its array elements?

I'm wondering if the elements of array can 'know' where they are inside of an array and reference that: Something like... $foo = array( 'This is position ' . $this->position, 'This is position ' . $this->position, 'This is position ' . $this->position, ), foreach($foo as $item) { echo $item . '\n'; } //Results: // This is...

Most Efficient way to Recursively Flatten Nested Array to Dot-separated string in Ruby?

I want to convert something like this: class NestedItem attr_accessor :key, :children def initialize(key, &block) self.key = key self.children = [] self.instance_eval(&block) if block_given? end def keys [key] + children.keys end end root = NestedItem.new("root") do children << NestedItem.new("parent_a") do...

C++ array initialization not working

I am trying to initialize an array of bools like so: bool FcpNumberIsOk[MAX_FCPS]={true}; but when I debug it, I only see the first element of the array initialized, the others are false. How can that be so? I am using Qt on ubuntu 10 and the initialization is done on a local array inside a method. Ok thanks for your answers. ...

Referencing a part of an array in C#.

Hi there, I have got the array containing some data, say, a header and a real data. I need to pass the data contained in the array to a method, but I definitely want to avoid copying it to another array. I thought of something like ArraySegment, but it seems not to work in my case (or maybe I'm wrong?). So, how to pass a part of an a...

Ajax script in a div not reading variables from parent

Hi, here is what I have (please excuse the crappy art): ------------------------------------------ |Menu | |----------------------------| | | |Big Div | | | | | | | | ------------------------ | | | | |Smaller Reloading Div | | | | | | ...

Array parameter passing in C#: why is it implicitly by reference?

Assume the following code, without any ref keyword, that obviously won't replace the variable passed, since it's passed as value. class ProgramInt { public static void Test(int i) // Pass by Value { i = 2; // Working on copy. } static void Main(string[] args) { int i = 1; ProgramInt.Test(i); ...

PHP : Problem with Arrays

Hi, I'm a php newbie, and I'm creating a Facebook application for my flash game. In the main page of the application, I want to print the current user friends sorted by score. I get first user friends using my application with this API function: <?php $friends = $facebook->api_client->friends_getAppUsers();?> $friends is an Array wit...

Can I get an array with Jquery $.post?

I using jquery's $.post to pull information from a database dynamically. This works fine if I want one item however, I would like to store each column as an array and pass the whole array over. I have the array but am having issues pulling it back to javascript so I can use it. Since the array will contain text with commas I can't use ...

PHP String in Array Only Returns First Character

Hi Everyone, For the next week, I'm stuck with a sadly very slow 1-bar EDGE internet connection, so forgive me if I didn't spend quite enough time researching this one, but I just set up a local server for testing code that I would normally test over the internet, and it doesn't seem to be working the same way on my local LAMP install. ...

Prepping comma delimited string for mysql's WHERE IN

I have the following string... 1,2,3,4,5,6 I want to have this like '1','2','3','4','5','6' To use in MySQL's WHERE IN () Would anyone know the best way to do this? Thanks! ...

Sort an associative array in php with multiple condition

Consider following array $details = array( array('lname'=>'A', 'fname'=>'P','membkey'=>700,'head'=>'y'), array('lname'=>'B', 'fname'=>'Q','membkey'=>540,'head'=>'n'), array('lname'=>'C', 'fname'=>'R','membkey'=>700,'head'=>'n'), array('lname'=>'D', 'fname'=>'S','membkey'=>540,'head'=>'y'), array('lname'=>'E', 'fname'=>'T','mem...

Select all based on category

function Check(chk) { if(document.myform.brandid.value!="Check all"){ for (i = 0; i < chk.length; i++) chk[i].checked = true ; document.myform.brandid.value="UnCheck all"; }else{ for (i = 0; i < chk.length; i++) chk[i].checked = false ; document...

convert array php

I want to convert this array content: $colorList[0] = "red"; $colorList[1] = "green"; $colorList[2] = "blue"; $colorList[3] = "black"; $colorList[4] = "white"; into array("red","green","blue","black","white") how do doing that? thanks ...

Create a new array from numpy array based on the conditions from a list

Suppose that I have an array defined by: data = np.array([('a1v1', 'a2v1', 'a3v1', 'a4v1', 'a5v1'), ('a1v1', 'a2v1', 'a3v1', 'a4v2', 'a5v1'), ('a1v3', 'a2v1', 'a3v1', 'a4v1', 'a5v2'), ('a1v2', 'a2v2', 'a3v1', 'a4v1', 'a5v2'), ('a1v2', 'a2v3', 'a3v2', 'a4v1', 'a5v2'), ('a1v2', 'a2v3', 'a3v2', 'a4v2', 'a...

Passing an array by reference in C# and managed C++.

Hi there, here is the situation: I want to call a method from a C++ module, and pass an array to it: x.Method(array, ...) x is a C# object. I would suppose that I could change the array and fill it with my own data - but it seems not be the case (?) How should I pass the array by reference and change its content in the method? Tha...

how to iterate subranges in a "cyclic array"?

I'm trying to write the following perl subroutine. Given are an array a of length n, an index i in the array (0<=i<n an upstream window length u and a downstream window length d. I want to iterate over the values in the upstream window and the downstream window to i. In the simplest case, this will iterating over the values in a[i-u..i...

php array conversion help needed

Hi, $cnt[0]=>Array( [0] => 0 [1] => 0 [2] => 0 ), $cnt[1] => Array ( [0] => 1 [1] => 0 [2] => 0 ) i want convert this array to below result, $cnt[0]=(0,0); $cnt[1]=(0,0); $cnt[2]=(0,1); any php function there to convert like this format, Thanks, Nithish. ...

How to create the histogram of an array with masked values, in Numpy?

In Numpy 1.4.1, what is the simplest or most efficient way of calculating the histogram of a masked array? numpy.histogram and pyplot.hist do count the masked elements, by default! The only simple solution I can think of right now involves creating a new array with the non-masked value: histogram(m_arr[~m_arr.mask]) This is not very...