arrays

how do i build an array in the test class

public static void main(String[] args){ Employee [] employeeList = { // build your list here }; } how exactly do i build my array. the array is just 2 strings that are defined in another class. class Employee { protected String name; protected String jobTitle; Employee(String n, String title) ...

Marshalling array of strings to char ** in C#. Must be quite easy (if you know how ;-)

Hi, I'm calling a C DLL function and need to supply the following C struct: typedef struct { char *mTableId; char **mFieldNames; int mNumFields; char *mFilter; char *mSort; int mOffset; int mMaxRecords; char *mTargetRecordFilter; int mSurroundingRec...

How to create a bmp file from rgb datas stored in a txt file?

Hi guys, I've to create a bmp image from two txt files.The first one is an mxn array: * * * * * * * * m n c11 c21 .. cm1 ... c1n c2n .. cmn * * * * * * * * * * * * * * * * 6 5 .7 .7 .6 1.0 1.2 .1 .9 .3 .7 1.1 .7 .2 1 1.1 1.2 1.3 1.7 .6 .5 .6 .5 .4 .9 .1101 2 .1 .1 .1 2.1 1.1 * * * * * * * * The second txt file is a color scale, like thi...

List of 1-indexed programming languages?

What programming languages are 1-indexed? So far I've got: Algol Matlab Action! Pascal and Fortran? EDIT: What he meant was languages whose array subscriptions start with 1 instead of 0 like in C. ...

Java declare array outside variable definition

I'm looking for a way to give a java array a value directly, outside of its declaration, for example /*this works*/ int a[] = {1,2,3}; /*this doesn't*/ a = {1,2,3}; the motivation is so that a method with an array as an argument can be used like this public void f(int a[]) { /*do stuff*/ } f({1,2,3}); instead of int a[] = {1,2,...

Can you store a function in a PHP array?

e.g.: $functions = array( 'function1' => function($echo) { echo $echo; } ); Is this possible? What's the best alternative? ...

Remove characters from a string in C

I only have access to 'C' and need to replace characters within a character array. I have not come up with any clean solutions for this relatively simple procedure. I am passed a character array, for example: char strBuffer[] = "/html/scorm12/course/course_index.jsp?user_id=100000232&course_id=100000879&course_prefix=ACQ&v...

downcasting an array in java (remove the unchecked warning game)

Hi all, I have a dumb silly question, but sometimes you have to ask them anyways. I got an Object[] instance in my left hand (it comes from non-generic swing) and a method that accepts a let's say Integer[] as its argument (in my case it's actually a vararg) in my right hand. I'm sure of the content of the array (or I'm ready to pay t...

javascript array sorting

barValues is an array I'm passing to a function. Within the function I have this: alert(barValues); var sortedBarValues = barValues; sortedBarValues.sort(function(a,b){return b - a}); alert(barValues); I'm trying to end up with two arrays. barValues being the original array and sortedBarValues being a copy of that array, now sorted....

php rand() array

I need to be able to pull a random value out of my array, let's assume i have array with 100 values, how can i pull randomly 5 values out of this array? ...

C: Function to swap values in 2D array

I'm trying to write a function to swap 2 elements in a 2D array: void swap(int surface[][], int x1, int y1, int x2, int y2) { int temp = surface[x1][y1]; surface[x1][y1] = surface[x2][y2]; surface[x2][y2] = temp; } however when I try to compile it (gcc), I get this error message: Sim_Annealing.c: In function `swap': Sim_...

How do you decipher complex declarations of pointers+arrays?

Although I use std::vector almost all the time, I am interested in understanding as much as I can about pointers. Examples of what I am talking about: char* array[5]; // What does it mean? // 1) pointer to an array of 5 elements! // 2) an array of 5 pointers? I am interested in the precise definition of this declaration. ...

How to create a variable length array/vector of String ^ in VC++

I'm trying to create a vector of System::String ^, I tried using the straight up STL vector, but vector<String ^> my_vector gives a C4439 error (function needs to have a __clrcall calling convention. So, I added __clrcall to my function prototype, and it still complained about my declaration of vector<String ^>. I'm also reading th...

Fastest/One-liner way to collect duplicates in Ruby Array?

What's the fastest/one-liner way to convert an array like this: [1, 1, 1, 1, 2, 2, 3, 5, 5, 5, 8, 13, 21, 21, 21] ...into an array of objects like this: [{1 => 4}, {2 => 2}, {3 => 1}, {5 => 3}, {8 => 1}, {13 => 1}, {21 => 3}] ...

storing an array in a file in java

Hello, I plan to store an array of numbers in a file and read it when needed. What would be a good way to do this? I can think of afew ways such as storing each element in a line as a text file or serialize it and store / call by that method. Speed is my first concern. Thanks ...

php array filter

I have and array (from json feed)... that array contain a lot of value, i only need some, so filter is the option... let say the array contain (a=2,b=4,c=2,d=5,e=6,f=2) I like to check all the value that is = 2, and DELETE the value that is not = 2 the resulting array will be (a=2, c=2, f=2) so a foreach or while will print ONLY the ...

Refering to arrays of form elements (name="blah[]")

I have a form with series of 3 file upload fields, each of which has a related hidden "todo" fields. The file upload fields start greyed out and a user can either upload a new file, remove a file if one has previously been uploaded in that position or leave it unchanged (i.e. use the previously uploaded file or leave it blank). The tod...

How to manipulate first 3 entries in array

Hi I am currently working on a project where i am pulling out data using while($r = mysql_fetch_array($the_data)) i want to make the first, say 3-4 results a different background color and then leave the rest as already styled, i am sure there is some simple option here but i just don't know where to look really... Hope you can help, ...

options for initialization a string array

what options do I have when initializing string[] object? ...

SSRS call web service and pass multi values array

I have a web service I need to call which is expecting a string Array. I'm using the standard VS SSRS and am having troubles setting up the Data Source in my project. I've setup DataSet parameters and tried a number of different options but it seems it will always pass the value as text. I get thrown the error (Expecting state 'Element...