arrays

Copy arrays from specific indexes

Hi, How can I copy an array of values to a destination array starting from a specific index without looping? For example,if I have an array with 2 values, I have to copy those two elements to another array which has a capacity of 5 starting from index 3? double[] source = new double[] {1, 2}; double[] destination = new double[5]{0,0...

How can I validate the structure of my PHP arrays?

Is there a function out there to make sure that any given array conforms to a particular structure? What I mean is that is has particular key names, perhaps particular types for values, and whatever nested structure. Right now I have a place where I want to make sure that the array getting past has certain keys, a couple holding a cert...

How can I include doxygen perlmod in my perlscript?

Hi How can I include doxygen perlmod in my perlscript? I've noticed that you can generate a alternative output with doxygen that is called perlmod, but I can't find any examples on how to use this part. I've found 2 nice files in there DoxyDocs.pm and DoxyStructure.pm, and they contain some kind of nice structure that represents th...

OutOfBoundsException for TicTacToe Game; Issue: arrays?

I am the beginnings of writing a tic-tac-toe game. I just ran it and got the following stack trace: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:571) at java.util.ArrayList.get(ArrayList.java:349) at TicTacToe.isMarked(TicTacToe.java:23) at TicTac...

Why am i getting "warning: assignment from incompatible pointer type"? Double linked list in a struct array

Hi, I'm trying to make an implementation of a double linked list which connects to an array. The struct that makes the array contains the list's Head and Tail pointer. typedef struct myStruct{ int code; struct myStruct *Head; struct myStruct *Tail; }myStruct; myStruct MyArray[10]; Here's my double linked list: struct myList { ...

How to display a set of combined posts and pages using Wordpress' query_posts() method.

I've got a template that I'm using that has the option of showing either a set of posts on the front page in a featured section or, optionally, display a set of specified pages in the same featured area. I found the code where it displays either/or, however I'm not exactly sure how to combine the two together and get a list of a set of ...

sortting multi-dimensional arrays

I would like to be able to sort this array by the element array's size; array( [0] => array( [0] => 'B', [1] => 'C'); [1] => array( [0] => 'B'); [2] => array( [0] => 'A', [1] => 'C'); [3] => array( [0] => 'A', [1] => 'B', [2] => 'C'); [4] => array( [0] => 'C'); [5] => array( [0] => 'A'); [6]...

Insert Element without Rewriting Existing Element in PHP Array

Hi, I have an array as follows Array ( [0] => application [1] => modules [2] => Ride [3] => externals [4] => images [5] => uploads [6] => profile [7] => 116 [8] => 13006678321287904362.jpg ) How can I insert an item to the existing array with out overwriting the existing element in specified index Consider I would like to create as...

PHP: variable (array) is function?

I dont understand the function of these characters -> in this code: $var->getImageInfo(); the function "getImageInfo()" populates the variable "$var". I can use the print_r function to display all values but how do I get a specific value echo "<pre>"; print_r($var->getImageInfo()); echo "</pre>"; returns Array ( [resoluti...

Extract a struct member from an array of structs

I have an array of structures that contain multiple variables: struct test_case { const int input1; //... const int output; }; test_case tc[] = { {0, /**/ 1}, // ... {99, /**/ 17} }; int tc_size = sizeof(tc) / sizeof(*tc); and I want to extract a vector of the outputs so I can compare them to another array...

Marshall an array of structs

I am calling a C++ function from C#. As arguments it receives a pointer to an array of structs. struct A { int data; } int CFunction (A* pointerToFirstElementOfArray, int NumberOfArrayElements) In C# I have created the same struct (as a class) and I marshall it correctly (the first element in the array is received correctly). He...

Java ArrayIndexOutOfBounds Exception

Hi, Perhaps I have been looking at this for too long as I cannot find the problem, yet it should be something simple. I am receiving an ArrayIndexOutOfBounds exception on the line: nextWord = MyArray[i + 1].toLowerCase(); Can anyone see why? String currentWord = ""; String nextWord = ""; for (int i = 0; i <= MyArray.length; ...

can i check in C(++) if an array is all 0 (or false)?

can i check in C(++) if an array is all 0 (or false) without iterating/looping over every single value and without allocating a new array of the same size (to use memcmp)? i'm abusing an array of bools to have arbitrary large bitsets at runtime and do some bitflipping on it ...

problem with JSON array as input to REST service

Hello All, I am using Apache CXF RS to produce a REST service which accepts both XML and JSON as input. I use the default JSON provider i.e. Jettison. My trouble starts when my input json has an array in it. For example, { person:{ telephone:[ { type: "mobile", number: "123" ...

Shortening an array based on consecutive occurences.

I'm in the middle of learning PHP, and the following list-related problem has come up. The language doesn't really matter, so I'll give you this in pseudo-code. Pseudo-code answers are fine, of course. Say, there's a list of two different, repeating elements - two single characters, for instance. So my list looks roughly like this: myL...

How can I find the most frequently recurring item in an array?

What would be the best approach to create the function getMostFrequentlyOccurringItem() below? //should return "paragraph" echo getMostFrequentlyOccurringItem(array('line', 'paragraph', 'paragraph')); //should return "line" echo getMostFrequentlyOccurringItem(array('wholeNumber', 'line', 'line', 'line')); //should return null echo get...

How to remove a character from a string using baskspace in C?

can you give me an example of deleting characters from an array of characters in c? I tried too much, but i didn't reach to what i want That is what i did: int i; if(c<max && c>start) // c is the current index, start == 0 as the index of the start, //max is the size of the array { i = c; ...

Add to NSMutableArray

I have 2 doubles with each iteration I want add to a NSMutableArray but I can't seem to make it happen. NSMutableArray *touchArray = [[NSMutableArray alloc]init]; [touchArray addObject:[NSString stringWithFormat:@"%d", "%d", tapTotal, touchBegin]]; NSLog(@"array: %@", touchArray); The console prints 14108 as the value for the ar...

Pointer to an array of pointers to Linked lists

hey guys right so i have been at this problem for the last 6 hours and have been hitting google like mad to no avail. Right I need a pointer to an array. This array contains pointers to Linked lists. Im going to have to malloc it since I dont know the array size until runtime. LList **array this was my first thought but this just give...

JavaScript - Sort an array based on another array of integers

Say I have an array: [0,3,4,2,5,1] What i want to do is sort an array such as: ["one", "two", "three", "four", "five", "six"] so that the order corresponds to the first array. This would be the output: ["one", "four", "five", "three", "six", "two"] Is there an easy way to accomplish this? ...