arrays

Performance issues with NSMutableArray and NSArray

I've been programming C/C++ for 20 years but I'm new to objective-c and Coco and have some questions about the performance of NSMutableArray and NSArray. I need an container much like the stl list container, but coco doesn't seem to have one and inserting and removing elements from the middle of MSMutableArray seems slow, but treating ...

Remove Movie clip as3

Ok this has been driving me nuts for the past couple of hours and i know there is an easy answer. I have a scrollPane which has a movie clip called right_container_mc as it's source. Inside this right_container_mc I have other other movie clips called execiseBox that get added (in the correct positions on the stage) from an array with a...

Splitting a Byte array in java

Is it possible to get specific bytes from a byte array in java? I have a byte array: byte[] abc = new byte[512]; and i want to have 3 different byte arrays from this array. byte 0-127 byte 128-255 byte256-511. I tried abc.read(byte[], offset,length) but it works only if I give offset as 0, for any other value it throws an ...

how to fill char **array thats in a struct

typedef struct _stats_pointer_t { char **fileNames; stats_t stats; } stats_pointer_t; I need to fill 'fileNames'. Basically, I need to mimic this functionality: char *fileNames[argc - 1]; fileNames[0] = argv[0]; ... but using the struct stats_pointer. So I need to declare the struct, then probably allocate memor...

Python: ball isn't defined

I get this error: Traceback (most recent call last): File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module> ball[i][j]=sphere() NameError: name 'ball' is not defined when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it? #2D-wave #VPython from visual import * #ball array #ready for i in ran...

PHP best way to MD5 multi-dimensional array?

Hi, i was wondering what is the best way to generate an MD5 (or any other hash) of a multi-dimensional array? I could easily write a loop which would traverse through each level of the array, concatenating each value into a string, and simply performing the MD5 on the string. However, this seems cumbersome at best and i wondered if t...

Java: Are there some quasi-standard APIs out there, which do int[] <-> Integer[] and similar?

Hello, everyone! I need to do lots of conversions between primitivetype[] and boxedtype[] (both directions). Such as: Integer[] <-> int[], Double[] <-> double[], ... I wanted to know, if there's some quasi-standards APIs out there, which provide such functionality, before I write such utility methods by myself. Java has 8 primitive ty...

JAVA--how to parse a JSON and turn its values into an Array?

public static void parseProfilesJson(String the_json){ try { JSONObject myjson = new JSONObject(the_json); JSONArray nameArray = myjson.names(); JSONArray valArray = myjson.toJSONArray(nameArray); for(int i=0;i<valArray.length();i++) { String p = nameArra...

Array to String Back to Array Conversion Problem

I'm saving a bunch of ID's to the session like this. session[:id_group] = 1,2,3,4,5 Because I need to save them to a data base with a form. In that form I have hidden-field : <%= form.text_field :group, :value => session[:id_group].inspect%> I use the inspect so that the value saved to the database gets to be [1,2,3,4,5] and not 1...

Matching arrays in php

I need check whether a given array will match another array. I can't figure out how to either manipulate the first array, or to match it some other way. I need to match this array: Array ( [1] => site [2] => blog [3] => index.php ) to match this: Array ( [site] => Array ( [path] => site ...

Comparing adjacent elements in MATLAB

Does anyone know how I can compare the elements in an array with the adjacent elements? For example, if I have an array: 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 Is there a way to cycle through each element and perform a logical test of whether the elements around it are equal ...

javascript php array

i have a js array like this: var myArray = []; myArray[1] = 'test'; myArray[2] = 'test'; -i want to hide it from users to see it. how can i store just the array in a php script and call it? right now i have the .js separate from my form. and i just call it. but anyone can easily view source and visit the url using the .js name -ano...

How do I allocate a 2 D array with contigious memory ? How Do I use it to access rows and columns? Give me an example.

I have created a 2 d array which reads as follows int i,j,lx,ly;// lx,ly are the row and column respectively double** a; a=(double**) malloc((lx+2)*sizeof(double)); a[0]= (double*) malloc((lx+2)*(ly+2)* sizeof(double)); assert(a[0]); for(i=1;i<lx+2;i++) { a[i]=a[i-1]+i*(ly+2); } // I...

How can I store captures from a Perl regular expression into separate variables?

I have a regex: /abc(def)ghi(jkl)mno(pqr)/igs How would I capture the results of each parentheses into 3 different variables, one for each parentheses? Right now I using one array to capture all the results, they come out sequential but then I have to parse them and the list could be huge. @results = ($string =~ /abc(def)ghi(jkl)mno(...

If key is the last in array?

How can i check if this key is the last in an array? $array = array("a","b","c"); The value "c" would have the key 2, is there some code like this is_end(2) which returns true or false depending if they key is the last of the array? Or is there some kind of while() statement I can do? ...

.NET Arrays datatypes

Hi folks, is it possible to store multiple datatypes in an array, if not, what could the reason be? TIA ...

unsigned array with keys in AS3?

hey how to create unsigned arrays with keys in actionscript 3? in php its simple: array('key' => 'val'); in ac3 you can create unsigned arrays like that: ['val'] ['key': 'val'] // breaks ...

How to create an Array from other Array?

Is there a way for creating an array from other severals arrays, in Objective C? ...

Inter-database communications in PostgreSQL

Hi, I am using PostgreSQL 8.4. I really like the new unnest() and array_agg() features; it is about time they realize the dynamic processing potential of their Arrays! Anyway, I am working on web server back ends that uses long Arrays a lot. Their will be two successive processes which will each occur on a different physical machine. E...

Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?

Given a simple zero based, numerically indexed array: var list = ['Foo', 'Bar', 'Baz']; Many times, I have noticed that when someone suggests looping through variables in an array like this: for(var item in list) { ... } ...there's almost certainly someone suggesting that that's bad practice and suggests an alternative approach: v...