arrays

How to create an NSMutableArray of floating point values

I'm new to Objective-C and iPhone development, and I'm trying to store floating-point values in an NSMutableArray, but when I do I get an error saying "incompatible type for argument 1 of 'addObject". What am I doing wrong? I'm trying to create an array of doubles that I can perform math calculations with. ...

How to delete an element from an array in C#

lets say I have this array int[] numbers = {1, 3, 4, 9, 2}; how can I delete an element by "name"? , lets say number 4? even arraylist didn't help to delete? string strNumbers = " 1, 3, 4, 9, 2"; ArrayList numbers = new ArrayList(strNumbers.Split(new char[] { ',' })); numbers.RemoveAt(numbers.IndexOf(4)); foreach (va...

Best way to convert an IEnumerable<T> to an T[]

What is the best way to convert from a generic IEnumerable object to an array of the same type? The current solution I have looks like the following: IEnumerable<string> foo = getFoo(); string[] bar = new List<string>(foo).ToArray(); The transfer through a List<T> seems unneccesary, but I haven't been able to find a better way to do ...

Generics List with Array return but how ?

These Codes really boring. And Tostring() give me error !!! Can you rearrange these codes ? class Program { static void Main(string[] args) { string[] arraystr = { "yusuf", "mehmet" }; Ilist myitems = new Ilist(arraystr); SelectedItemsList slist = new SelectedItemsList(); ...

Why does cout print char arrays differently from other arrays?

I'm using C++ to understand how exactly pointers work. I have this piece of code using arrays, which I'm using just to understand how the equivalent works with pointers. int main() { int arr[10] = {1,2,3}; char arr2[10] = {'c','i','a','o','\0'}; cout << arr << endl; cout << arr2 << endl; } However when I run th...

How to obtain the mirror image of an array (MATLAB)?

Problem: array1 = [1 2 3]; must be converted in array1MirrorImage = [3 2 1]; So far I obtained the ugly solution below: array1MirrorImage = padarray(array1, [0 length(array)], 'symmetric','pre'); array1MirrorImage = array1MirrorImage(1:length(array1)); There must be a prettier solution to this. Anyone knows one? ...

Passing pointers of arrays in C

So I have some code that looks like this: int a[10]; a = arrayGen(a,9); and the arrayGen function looks like this: int* arrayGen(int arrAddr[], int maxNum) { int counter=0; while(arrAddr[counter] != '\0') { arrAddr[counter] = gen(maxNum); counter++; } return arrAddr; } Right now the compilier tells me "warning: passing argume...

Basic array initialization and sorting question.

Hi this is a rather basic java question I have an array containing String that i want to sort using java.util.Arrays.sort when i write String[] myArray = {"A","B","C"}; java.util.Arrays.sort(myArray); it gets sorted correctly however when i have String[] myArray = new String[10]; myArray[0] = "A"; myArray[1] = "B"; myArray[2] = "...

How do I return an array from a Visual FoxPro 9 OLEPUBLIC class?

As a newbie to FoxPro (but an old-hand at Clipper), I'm a bit at a loss to figure out how to return an array from the following OLEPUBLIC class. edit: I've modified the code belw to take into consideration the remarks made by @Stuart below. DEFINE CLASS db AS CUSTOM OLEPUBLIC DIMENSION ada(1) && public scope for later return FUNCTI...

mailchimp api & array question

I'm having a bear of a time getting the mailchimp api to cough up info. In their example I'm fine (the first is an abridged version of theirs.) How come when the method changes I can't get the array to show the collected information? why is this valid: (it's taken from here http://www.mailchimp.com/api/rtfm/campaignemailstatsaimall.func...

Moving objects inside arrays

Hello! I'm trying to make a Tetris-like game in XNA, and currently I'm thinking of what way would be the best to handle it. This is what I have so far: I have a class called Block, which has for example texture and color tint. Then I was planning on having everything in a double array, like: Block[,] blocks = new Block[10,20]; which...

How can I compare two arrays and list differences in PHP?

I'm building a form to do the following: Print a table of users and permissions, pulling from MySQL. Each permission a user has is a checked box, and each one they lack is an unchecked box. Allow an administrator to check and uncheck boxes to grant or remove permissions. When the form is submitted, show a confirmation page with ONLY ...

How can I compare the values in two arrays?

It seems that every PHP function I read about for comparing arrays (array_diff(), array_intersect(), etc) compares for the existence of array elements. Given two multidimensional arrays with identical structure, how would you list the differences in values? Example Array 1 [User1] => Array ([public] => 1 [private] =>...

Size of array in Visual Basic?

I've tried this code in VB: Dim a(1) As Byte Console.WriteLine(a.Length) The output is "2". Anyone any idea why? ...

How to marshal unmanaged buffer of packed structs in c#

Hello I am (successfully) calling the Windows FilterSendMessage function in c# using the following pinvoke signature: [DllImport("fltlib.dll")] public static extern IntPtr FilterSendMessage( IntPtr hPort, IntPtr inBuffer, UInt32 inBufferSize, IntPtr outBuffer, UInt32 outBufferSize, ou...

PHP - Outputting specific content from an array.

How do I output the [Comment][title]s one after another in this array? Array ( [User] => Array ( [id] => 121 [name] => Gwoo the Kungwoo [created] => 2007-05-01 10:31:01 ) [Comment] => Array ( [0] => Array ( [id] => 123 ...

Multidimensional array in Python

Hi, I have a little Java problem I want to translate to Python. Therefor I need a multidimensional array. In Java it looks like: double dArray[][][] = new double[x.length()+1][y.length()+1][x.length()+y.length()+3]; dArray[0][0][0] = 0; dArray[0][0][1] = POSITIVE_INFINITY; Further values will be created bei loops and written into the...

Why do arrays start from zero?

Duplicate of: Defend zero-based arrays Why did the computer programming inventors have the brilliant idea of making arrays start with index zero and leave us all doing myArray.length()-1 when they knew that the logical thing would be to have the index start from 1? Is it some sort of backwards compatibility due to which all (even...

Do the keys of javascript associative arrays need to be strings, or can they be any object?

that's it, that's my question. thanks! -Morgan ...

creating a object in javascript that has a 'init' method with optional name/value pairs

I've seen many javascript objects that have a 'init' method that you pass in values to in order to setup the object. How do they internally handle the initializations of their private variables when passed in a array of name/value pairs like: myObject.init( {prop1: "blah", prop2: "asdf", ..., propn: "n"} ); Specifically, some ...