arrays

Memory leak with an array - objective c

Hi, am having some trouble with attempting to remove a memory leak from my code. In the code below, I get a memory leak on the line "configurationArray = [[NSArray arrayWithContentsOfFile:controllerConfigurationFilePath] retain];" however when I remove the retain, the application crashes and changing the retain to an autorelease also cau...

Confused in how to print an array hellically

I have been trying to figure out how can we print a array hellically but i am stuck on how to get started.Any algorithms or ideas will be very helpful.Thanks HELLICALLY means printing the array in concentric circular shape ...

i've got some problems with my spinner..

So i'm starting a application and the first thing to do is make a description of a city when the city is selected. I can show the description but it make the description of all the cities on the same time and it don't come out when i select another city : it add more and more . this is my code : public class Main extends Activity imple...

What is the correct syntax to use perl array of hashes with regex? example gets hyperlinks from page

@urls= $field =~ /<a.*?href="(.*?)".*?>.*?<\/a>/mgo; #multi-line, global, compile-once @text= $field =~ /<a.*?href=".*?".*?>(.*?)<\/a>/mgo; for ($count=0; $count<(scalar @urls); $count++){ print "\"".$text[$count]."\" goes to ->\"".$url[$count]."\"\n";} What is the correct syntax to make this the same as the previous lines? (@arra...

Javascript: What's a better way to splice arrays together than what I'm using now?

var newlist = list.slice( 0, pos ).concat( tasks ).concat( list.slice( pos ) ); This makes me shudder just looking at it. ...

Best way to initialize class's inherited member var of type std::array?

Entity has a member var of type std::array. Student inherits from Entity, and will need to initialize the std::array member var it inherited. Below is the code I'm using to do this, but it involves casting a brace-enclosed list to std::array. I'm not sure this is the correct or optimal way to do this. Using a brace-enclosed or double...

PHP array post data

Form: $headerValues=array(); $headerValues[1][2]="Test"; ... .... echo "<input type=\"hidden\" name=\"ArrayData\" value=\"$headerValues\"/>"; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\" />"; How do I read headerValues on FORM POST , I see as ARRAY when I use this code foreach (array_keys($_POST) as $key) { ...

why different answers?

Below are 2 programs First #include<stdio.h> void main() { int a[5]={1,2,3,4,5}; int *p; p=&a; printf("%u %u",p,p+1); } Second #include<stdio.h> void main() { int a[5]={1,2,3,4,5}; printf("%u %u",&a,&a+1); } Now, in the two programs..I have printed the values of &a using p in first code and directly in th...

Rotate an array using LINQ syntax

I am solving this problem of rotating an array and got algorithm and code working int[] Rotate(int[] ar,int k) { if (k <= 0 || k > ar.Length - 1) return ar; Reverse(ar, 0, k - 1); Reverse(ar, k, ar.Length - 1); Reverse(ar, 0, ar.Length - 1); return ar; ...

Practical use of N-Dimensional Arrays,where (N>3)

I have been programming for the last 8 years and now I was just wondering that if there is any practical use of N-Dimensional array,where N>3.I can only visualize of a data structure that is less than or equal to 3 dimensions.Has any one used more than 3 dimensions in any program?Are there any practical uses of a N-D array which is beyo...

php arrays - in_array and/or array_intersect

It's another day for being thickso sorry. :) Anyhow, I have 2 arrays that I want to manipulate; if a value from the first array exists in the second array do one thing and then do something else with the remaining values of the second array. e.g. $array1 = array('1','2','3','4'); - the needle $array2 = array('1','3','5','7'); - the hay...

using jquery.InArray() if i have a collection of objects

in my javascript, i have an Array of Calendar objects. Each Calendar objects has an array of CalendarEvent objects Each CalendarEvent object has a property Date, Name. i want to check, give a date, it its exists in a specific Calendar. I wanted to see if i could use jquery.InArray() but it seems like i have to loop through every Cal...

in c#, how do i convert this data structure into Json

In C# i have an array of Calendar objects each Calendar object has an array of CalendarEvent objects each CalendarEvent object has a Date and Name property i want to convert this to Json object but i want to change the data structure a bit so in the json object a calendar is an array of dates and an array of names (breakdown the Calen...

array index and address return same value.

#include<stdio.h> int main(void) { int a[3] = {1,2,3}; printf("\n\t %u %u %u \t\n",a,&a,&a+1); return 0; } Now i don't get why a and &a return the same value, what is the reasoning and the practical application behind it? Also what is the type of &a and could i also do &(&a) ? ...

array is of same type and linked list is of different type

In an interview when I ask the recent graduate students that what is the difference between array and linked list, the first answer normally is "In array you have same data types and in the linked list you can have different data types." When I told them to explain they will say that they have just read it somewhere or that they don't kn...

Java ArrayList of Arrays?

I want to create a mutli dimensional array without a fixed size. I need to be able to add items of String[2] to it. I have tried looking at: private ArrayList<String[]> action = new ArrayList<String[2]>(); but that doesn't work. does anyone have any other ideas? ...

Accessing an array element when returning from a function

Some searching through Google (and my own experience) shows that in PHP you can't grab an array element when it's been returned from a function call on the same line. For example, you can't do: echo getArray()[0]; However, I've come across a neat little trick: echo ${!${false}=getArray()}[0]; It actually works. Problem is, I do...

Efficient Array Normalization of Approximate Values

I'm looking for the efficient way of replacing approximate values (ushort[100]) for their target values. There are two target values (ushort x, 2x), each value in the ushort[] approximates one of these two. ...

subarrayWithRange with large data

iPad application I have a large text file which I want to divide into several pieces and process them in a loop. I used the following code: NSArray * contentArray = [stringFromFile componentsSeparatedByString:@" "]; for(...){ contentRange = NSMakeRange(lastPosition , newLength); NSArray * subContentArray = [contentArray subarr...

How to save my own object with NSKeyedArchiver??

Hi, i've got problems using the NSKeyedArchiver/NSKeyedUnarchiver for saving my object. I added the methods - (id)initWithCoder:(NSCoder *)decoder and - (void)encodeWithCoder:(NSCoder *)encoder. The problem is when i try to save the object it doesn't work correctly. I could imagine a problem (but I'm not sure if it is the problem ;) ). ...