arrays

How to make tr1::array allocate aligned memory?

You can allocate a std::vector which allocates aligned heap memory by defining your own allocator. You can allocate a c-style array on the stack using declspec align. But can you declare a tr1::array which guarantees that the element at index zero will be aligned? ...

Convert array<int^>^ to int*

how can I convert array<int^>^ to int*? ...

Multidimensional array of object in C++ , I can not initialize it!

Hi everyone! Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at creating an array of arrays. All objects I wish to store I want to put on the heap. In the arrays it's all just pointers. Here's some code: Grid.h #include "Tile.h" class Grid { public: Tile* grid_ptr[8][8]; ... ... }; Grid.c...

Rails: Serialize value as comma-seperated and not as YAML

Hi there, I'm looking for a way to store a serialized value of eg. IDs in a column. In before claims that this is not an optimal design: the column is used for IDs of associated records, but will only be used when displaying the record - so no queries are made with selection on the column and no joins will be made on this column either....

trying to update an array element in java

I'm trying to update an array element in Java. Some sort of a database like program, but using an array to store data temporarily. The code seems to be working only on the first array element which is 0. If I try to search for other records, it cannot find them. I don't know why. boolean blnFound=false; String strP=getString("Inpu...

PHP - Sorting an Array

Hello everyone, I am trying to sort an array that contains numbers that range in substantial values. The result I want to get is a descending order of those numbers from the array I am retrieving from a MySQL Server. So far I have created this to test out the "sort" function: <?php $numbers = array("100", "50", "70", "1000"); sort($nu...

Python: shape of a matrix and imshow()

Hello! I have a 3-D array ar. print shape(ar) # --> (81, 81, 256) I want to plot this array. fig = plt.figure() ax1 = fig.add_subplot(111) for i in arange(256): im1 = ax1.imshow(ar[:][:][i]) plt.draw() print i I get this error-message: im1 = ax1.imshow(ar[:][:][i]) IndexError: list index out of range Why do I g...

How do I change the order of several tables based on mouse wheel scrolling in jQuery?

Hi ! I have a div (#thelist) that contains a bunch of html tables. When the mousewheel is turned i want the first table to be removed and added to the bottom. (And the other way around if the wheel is turned in the other direction). For some reason the code below works also from my understanding the list should juts get longer and long...

Array slicing in Ruby: looking for explanation for illogical behaviour (taken from Rubykoans.com)

I was going through the exercises at http://rubykoans.com/ and I was struck by the following Ruby quirk that I found really unexplainable: array = [:peanut, :butter, :and, :jelly] array[0] => :peanut #OK! array[0,1] => [:peanut] #OK! array[0,2] => [:peanut, :butter] #OK! array[0,0] => [] #OK! array[2] => :and #OK! array[2,2] ...

how to use mvcArray on google maps v3

i can use the methods like : push removeAt setAt but how to use the Events ? like: insert_at remove_at thanks ...

get first element of javascript array

I have an array of objects in javascript. I use jquery. How do i get the first element in the array? I cant use the array index - as I assign each elements index when I am adding the objects to the array. So the indexes arent 0, 1, 2 etc. Just need to get the first element of the array? ...

problem initializing large double array

Hi, Silly question from a new C programmer... I get a segmentation fault in the following code: #include <stdio.h> int main(void) { double YRaw[4000000]={0}; return 0; } Using GDB, I get the following comment: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5dd7b...

Coverting a string of tags to an array

I have a string of tags that are usually separated by a single space, but the spacing may be inconsistent due to user input, hence the multiple spaces I added. $somestring = "<h1> <a> <h5> <img> <a> <strong>"; I'd like to store the tags into an array instead for easier manipulation. How can this be done with PHP? ...

Initialise 2D array pointer to char globally

I have a 2-dimensional array of pointer to char and initialising it in a header file. The problem is this: it doesn't complain getting assigned a const char[] but does not like me assigning const char* (as shown in the code). It gives me an error "initializer element is not constant". const char lang[8] = "English"; const char * langPt...

Find if a String is present in an array

OK let's say I have an array filled with {"tube", "are", "fun"} and then I have a JTextField and if I type either one of those commands to do something and if NOT to get like a message saying "Command not found". I tried looking in Java docs but all I am getting is things that I don't want like questions and stuff... so, how is this don...

Shorter syntax for this array insertion

Is there a better syntax for this array insertion in PHP? The array already has items and I'm adding items to it. I hate that I have to repeat the array name multiple times like this $somearray[] = "new item 1"; $somearray[] = "new item 2"; $somearray[] = "new item 3"; ...

How much memory array of objects in c# consumes?

Suppose that we have previously instantiated three objects A, B, C from class D now an array defines as below: D[] arr = new D[3]; arr[0]=A; arr[1]=B; arr[2]=C; does array contains references to objects or has separate copy? ...

Javascript merge objects in array by values

In Javascript, I have an array with objects that looks like this: var arr = [ { value_1: 0, value_2: 4, encounter_bits: { min_level: 8, max_level: 12, rarity: 20, conditions: [1, 5] } }, { value_1: 1, value_2: 4, encounter...

Removing any (first, middle, last, single) item in a CSV list via PHP's explode / implode

$pieces = explode(",", $userList); $key=array_search($deleteuser, $pieces); if(FALSE !== $key) { unset($pieces[$key]); } else return FALSE; $userList = implode(",", $pieces); I'm looking for inputs into how to rework this code to remove an element from a CSV list. The user should exist in this system and it should work fine e...

Groovy / Java method for converting nested List String representation back to List

I need to convert a String representation of a nested List back to a nested List (of Strings) in Groovy / Java, e.g. String myString = "[[one, two], [three, four]]" List myList = isThereAnyMethodForThis(myString) I know that there's the Groovy .split method for splitting Strings by comma for example and that I could use regular expres...