arrays

Creating an Array of JLabels

I'm trying to create 5 Jlabels using netbeans GUI Design, the Labels are supposed to display 5 different values. I need to combine these 5 JLabels in 1 array of Labels. is there any options in the design that let me do that? ...

Passing an array as an argument in C++

I'm writing a merge sort function, and right now I am just using a test case array (there is no input - this is static, for now). I don't know how to pass an array as an argument. Here is my code right now: //merge sort first attempt #include <iostream> #include <algorithm> #include <vector> int mergeSort(int[]); int main() { int orig...

PHP: Get text separated by commas

Hi, I have a multidimensinal array.. Something like this for example: Array ( [0] => Array ( [title] => Star Trek - Viaje a las estrellas [country] => Venezuela, Spain, long title, poster title ) [1] => Array ( [title] => Viaje a Las Estrellas [country] => ...

VB.net 2008 Property Array

Hi can anyone help here? I am currently learning VB.net but for a project I need to create and array and pass it using a property. The data to be passed will be a train's destination, the time its due and the expected time of the train. I was wondering if someone could simplly explain how to first produce an array and then show how to pa...

How to shift array elements

Hi, I have an array of n = 32 items with positive and negative values. First n/2 elements are positive and sorted by value and second n/2 elements are negative and sorted by value as well. I would like to sort the whole array by value, starting from the smallest negative value to biggest positive value which means if there are 32 elemen...

2d arrays, input files... Error: empty String (?)

This is my assignment: link Here are my questions: How can I fix this error: Exception in thread "main" java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1012) at java.lang.Double.parseDouble(Double.java:527) at extracredit.Main.read...

Casting away the const-ness in an array of pointers to const, and other questions regarding C

I have a bit of code I'm running to test multithreading in MATLAB mex functions (I know MATLAB isn't thread safe... I'm just playing around to see what happens). The entry point to MATLAB C code functions has the signature of the mexFunction function in the code snipped at the bottom of the post. Since I want to essentially pass the ar...

Help pulling out data from a PHP array based on 5 rules

I'm working with arrays of image filepaths. A typical array might have 5 image filepaths stored in it. For each array, I want to pull out just the "best" photo to display as a thumbnail for the collection. I find looping and arrays very confusing and after 4 hours of trying to figure out how to structure this, I'm at a loss. Here are...

How do you check if a variable is an array in JavaScript ?

I would like to check whether a variable is either an array or a single value in JavaScript. I have found a possible solution... if (variable.constructor == Array)... Is this the best way this can be done? ...

How to str_pad this PHP date selection month array ???

Needs to be padded to this: str_pad($Month, 2, "0", STR_PAD_LEFT) but how/where??? /*******creates the month selection dropdown array****/ function createMonths($id='month_select', $selected=null) { /*** array of months ***/ $months = array( 1=>'Jan', 2=>'Feb', 3=>'M...

Manipulating the structure of a multidimensional array

This is actually a problem that I've already solved, but I suspect that there may be a better solution. I have a nested array which basically represents a list of all the nodes from a category tree (in no particular order): Array( [0] => Array( [Category] => Array( [id] => 49 [name] => Poster ...

How can I master the idea of arrays?

I totally understand the purpose of arrays, yet I do not feel I have "mastered" them. Does anyone have some really good problems or readings involving arrays. I program in PHP and C++ so if there are examples with those languages that would be preferable but is not necessary. ...

Ruby: Want a Set-like object which preserves order

... or alternatively an Array which prevents duplicate entries. Is there some kind of object in Ruby which: responds to [], []= and << silently drops duplicate entries is Enumerable (or at least supports find_all) preserves the order in which entries were inserted ? As far as I can tell, an Array supports points 1, 3 and 4; while a Se...

C hard coding an array of typedef struct

This is such a dumb question it's frustrating even asking it. Please, bear with me, I'm feeling particularly dumb over this one today.... I've got a library with a certain typedef struct. basically: typedef struct {int x; int y;} coords; What I really wanted to do was declare in my header a variable array of this: coords MyCoord...

Add an array of buttons to a GridView in an Android application

I have an application that will have 5-15 buttons depending on what is available from a backend. How do I define the proper GridView layout files to include an array of buttons that will each have different text and other attributes? Each button will essentially add an item to a cart, so the onClick code will be the same except for the...

Ignorance OR bug on PHP's "foreach" construct?

I have a dataset obtained from MySQL that goes like this: Array ( [0] => Array ( [views] => 14 [timestamp] => 06/04 [views_scaled] => 4.9295774647887 [unix_time] => 1239022177 ) [1] => Array ( [views] => 1 [timestamp] => 19/04 ...

Where is it legal to use ruby splat operator?

Splats are cool. They're not just for exploding arrays, although that is fun. They can also cast to Array and flatten arrays (See http://github.com/mischa/splat/tree/master for an exhaustive list of what they do.) It looks like one cannot perform additional operations on the splat, but in 1.8.6/1.9 the following code throws "unexpected ...

Check for Nothing in vbscript/classic asp

I need to update an old classic asp, and I have to call a function that normally returns an array, but under certain circumstances might return either Nothing or an undefined value. How can I check that the result actually returns an array? ...

Sorting an associative array in PHP

I have an array in this format: Array ( [0] => Array ( [text] => tests [language] => [advertiserCompetitionScale] => 5 [avgSearchVolume] => 7480000 [lastMonthSearchVolume] => 9140000 ) [1] => Array ( [text] => personality tests ...

What is an array/ordered lookup database?

I'm looking for a database that supports the following functionality: 1) Records in the database are like Python dictionaries or Perl hashes. For example, a "purchase" record might look like this: <purchase 5436> = { product: "BMX Bike", price: 99.50, city: "Springfield" } 2) The records are stored in arrays of variable length. The d...