arrays

[Flex 3] Updating runtime created arraycollections, they all have the same source

Hello. I have a source collection (now a simple Array). At run-time I create ArrayCollections using the same array as the source (each collection show the same source, but they are differently filtered). My problem is, when a new item added to the source, the already created arraycollections wont updated if one of the property of this n...

ALLOCATABLE arrays or POINTER arrays?

Hello, I am writing a new code in Fortran and hesitating between using allocatable arrays or pointer arrays. I read somewhere that allocatable arrays have significant advantages over pointer arrays: 1) More efficient because they are always contiguous in memory 2) No memory leaks are possible Can someone confirm this? Which one wou...

PHP class function will not change an array

I am new to PHP and programming in general. I have been working on a few things with PHP that have required me to create classes, which has been fine, except that I can't seem to get my class methods to work on arrays that are properties of the class. I must be doing something pretty fundamentally wrong, because it doesn't seem to work r...

Fill an array with clones of a single object

What is a quick and easy way to fill a Java array with clones of a single object? e.g. after: Rectangle[] rectangles = new Rectangle[N]; fillWithClones(rectangles, new Rectangle(1, 2, 3, 4)); the rectangles array would contain N distinct Rectangle instances, initialised with the same coordinates. I am aware of the flaws of Object.cl...

Need a repeatable random array shuffle using a key

I am looking to randomly shuffle a list/array using a key. I want to be able to repeat the same random order using the key. So I will randomly generate a numeric key from say 1 to 20 then use that key to try and randomly shuffle the list. I first tried just using the key to keep iterating through my list, decrementing the key until=0,...

Delphi array initialization

I currently have this, and it sucks: type TpointArray = array [0..3] of Tpoint; class function rotationTable.offsets(pType, rotState, dir: integer): TpointArray; begin Result[0] := point(1, 1); Result[1] := point(1, 2); Result[2] := point(1, 1); Result[3] := point(1, 1); end; but instead, i want to do something like this: c...

How to make something to let the user change the language in a multilingual website that uses php arrays?

I followed the following tutorial to build a multilingual webpage using php arrays: http://bytes.com/topic/php/answers/880915-how-develop-multi-lingual-websites-php the code: files tree: locale/ english.php french.php set_locale.php index.php locale/english.php: <?php $locale = array( 'title' => 'Title in English', ...

How to maintain the previously selected language (I used php arrays and ?lang=) after clicking a link?

I have the following code: <html> <head> <title><?php echo $GLOBALS['L']['title']; ?></title> </head> <body> <ul id="language-selection"> <li><a href="index.php?lang=english">English</a></li> <li><a href="index.php?lang=french">French</a></li> ...

How to sort an array of objects based on a the length of a nested array in javascript

I have an array of objects in javascript, each of which in turn has an array: { category: [ { name: "Cat1", elements : [ { name: name, id: id } ] }, { name: "Cat2", elements : [ { name: name, id: id }, { name: name, id: id }, { name: name, id: id } ] ...

Return an array in c++

Suppose I have an array int arr[] = {...}; arr = function(arr); I have the function as int& function(int arr[]) { //rest of the code return arr; } What mistake am I making over here?? ...

Taking user input with pointers

I'm trying to get better at using pointers, and not using array notation. So I have a function to read user input and return a pointer to that array. I can do it like this and it seems to work ok: float *GetValues(float *p, size_t n) { float input; int i = 0; if ((newPtr = (float *)malloc(n * sizeof(float))) == NULL) ...

What is the fastest way to initialize all elements in an array to NaN?

In C# .NET, what is the fastest way to initialize an array of doubles to NaN? Here is how I am presently initializing an array with many elements. int length = array.Length; for(int i = 0; i < length; i++) { array[i] = double.NaN; } Is there a faster way? ...

in_array but needle is array, what the alternative for it

I have 2 array, the value will be from database, below is the case example: $arr1 = array(1,2,3); $arr2 = array(1,2,3,4,5,6,7); What I want to do is to check if all values in $arr1 is exist in $arr2. the above example should be a TRUE while: $arr3 = array(1,2,4,5,6,7); comparing $arr1 with $arr3 will return a FALSE. Normally I use...

How can I store regex captures in an array in Perl?

Hey everyone, I'm trying to use regex in Perl. What I was wonder was if it is possible to store all matches to the expression into an array? I know I can use the following: ($1,...,$n) = m/expr/g; but it seems as though that can only be used if you know the number of matches you are looking for. I have tried my @array = m/expr/g; but ...

How do I declare an array created using malloc to be volatile in c++

I presume that the following will give me 10 volatile ints volatile int foo[10]; However, I don't think the following will do the same thing. volatile int* foo; foo = malloc(sizeof(int)*10); Please correct me if I am wrong about this and how I can have a volatile array of items using malloc. Thanks. ...

How can I check if all elements of an array are identical in Perl?

I have an array @test. What's the best way to check if each element of the array is the same string? I know I can do it with a foreach loop but is there a better way to do this? I checked out the map function but I'm not sure if that's what I need. ...

Efficiency: arrays vs pointers

Memory access through pointers is said to be more efficient than memory access through an array. I am learning C and the above is stated in K&R. Specifically they say Any operation that can be achieved by array subscripting can also be done with pointers. The pointer version will in general be faster I dis-assembled the following ...

Delphi "array of const" to "varargs"

Please help! I need this conversion to write wrapper for some C headers for Delphi. As an example: function pushfstring(fmt: PAnsiChar): PAnsiChar; cdecl; varargs; external; ... function PushString(fmt: AnsiString; const args: array of const): AnsiString; begin Result := AnsiString(pushfstring(PAnsiString(fmt), args)); // it's inco...

array as session variable.

Is it possible to make an array a session variable in php. The situation is I've a table(page 1) with some cells having a link to particular page. The next page will have a list of names(page 2 which I want to keep in session array) with their respective check box. on submitting this form which will lead to transaction page(page 3 here v...

Malloc a 3-Dimensional array in C?

Hey all, I'm translating some MATLAB code into C and the script I'm converting makes heavy use of 3D arrays with 10*100*300 complex entries. The size of the array also depends on the sensor's input, ideally the array should be allocated dynamically. So far I've tried two approaches the first being a flat 1D array along the lines of va...