arrays

Is it breaking Facade design pattern

In HomeCADEngine facade class I have a method "addRoom(room:Room)" and it will add this room to a ArrayList. But is it break facade pattern when we create a room outside facade class and then pass it into addRom() method?? Many thanks ...

How to literally define an array of decimals without multiple casting?

How can I define an array of decimals without explicitly casting each one? //decimal[] prices = { 39.99, 29.99, 29.99, 19.99, 49.99 }; //can't convert double to decimal //var prices = { 39.99, 29.99, 29.99, 19.99, 49.99 }; //can't initialize... decimal[] prices = { (decimal)39.99, (decimal)29.99, (decimal)29.99, (decimal)19.99, (decima...

Post an array in input elements using jquery

Hi Basically I've got textboxes called dimension[0][scale], dimension[0]width etc. How do i pass the the elements 'dimension' as an array? I've tried $('input[name=dimension]').serialize() and doesnt seem to work. ...

What is the best way to String.Join a non-string array?

What is a shorthand way to String.Join a non-string array as in the second example? string[] names = { "Joe", "Roger", "John" }; Console.WriteLine("the names are {0}", String.Join(", ", names)); //ok decimal[] prices = { 39.99M, 29.99m, 29.99m, 19.99m, 49.99m }; Console.WriteLine("the prices are {0}", String.Join(", ", prices)); //bad ...

Undefined behaviour (?) in C with char arrays

when i try char bla[32] = "foobar"; int i; putchar(bla[i]); with strlen(bla) < i < 32, bla[i] is always \0. but isn't this in fact undefined behaviour, and should be avoided? ...

Can i use dictionaries as matrices in python?

I am just a beginner in python. Recently i am learning to use dictionaries but my knowledge in it is still limited. I have this idea popping out from my head but i am not sure whether it is workable in python. I have 3 document looks like this: DOCNO= 5 nanofluids :0.6841 introduction:0.2525 module :0.0000 to :0.0000...

Most optimized/effective way to convert a collection into an array?

I know it must have been asked more than twice, but I could not find any applicable question to answer the matter. I have a collection which I wish to retrieve an array from in .NET 2.0. In other words, I want to convert a collection into an array. So far I have the following: Public Class Set(Of T) Implements IEnumerable(Of T) ...

jQuery get array values from url

I've got an url like this: http://www.somewhere.com/index.html?field[]=history&amp;field[]=science&amp;field[]=math Using jQuery, how can I grab the GET array? Thanks. ...

replace items which appear in both arrays in javascript

hi, well, i have two arrays and want to remove in one of them, all elements which exist in the other as well. is there a native JS possibility? is there a jQuery functino? what is best practice to do so (the faster the better) thanks p.s.: just post code in other languages too, maybe i can port it to javascript Update, after accep...

C Fixed array pointing to parts of an array

I'm doing a project where I struck against this situation: typedef unsigned char Page[16384]; unsigned char Memory[16384*64]={...values...}; void foo(Page* page); Now as you can see Memory is composed of "Pages", now I would like to pass a Page to a function but a Page should be a POINTER to values of Memory (so indexes of a Page shou...

categories and items 1 big array

I've made some search on the forum without any good answers for my problem. If I missed something, feel free to link me to the question! What I need to do is simple: a function that returns an array of the full tree of my categories and items. I only have 1 depth (item and a cat_id), so no recursion involved (though if you have a recurs...

Merging structs with same user id and then sorting based on attributes...

I have any array of structs. Each struct in the array has the following attributes: user_id num_hot_dogs_eaten date_last_pigged_out Here's what I want to do: Find the structs with matching user_id's, and merge them into one struct record where num_hot_dogs_eaten is the sum of all matching records and date_last_pigged_out is the m...

Are there any jquery features to query multi-dimensional arrays in a similar fashion to the DOM?

What the question says... Does jQuery have any methods that will allow you to query a mult-dimensional array of objects in a similar fashion as it does with the DOM. So for instance, get me a list of objects contained within a multi-dimensional array having some matching property value - for instance where StartOfPeriod greater than a ...

How to Store a Mixed Array in Core Data

I need to store two types of objects, Feed and Folder, in an array in Core Data. For example: Array Feed Feed Folder Feed Folder Folder …etc... I know about BWOrderedManagedObject for storing objects in order in Core Data, but I'm not sure how to store mixed objects (the array needs to be mixed, since the i...

change speed of an array loop? Objective-C

I have this code NSArray *food = [NSArray arrayWithObjects:@"Apples:",@"bacon",@"corn",@"donuts",@"elfs",@"fidge",nil]; for(int i = 0; i<6; i++){ NSLog(@"item at index %i is %@",i,[food objectAtIndex:i]); } and right now they are all printed to the console instantly. How can I make a variable to decrease or increase the speed th...

Pushing a static array into a std::vector?

I'm trying to do the following: I have: std::vector<std::vector<GLdouble[2]>> ThreadPts(4); then I try to do: GLdouble tmp[2]; while(step--) { fx += dfx; fy += dfy; dfx += ddfx; dfy += ddfy; ddfx += dddfx; ddfy += dddfy; tmp[0] = fx; tmp[1] = fy; ThreadPts[currentvector].push_back(tmp); } ...

NSThread to slow down Array being printed to console in Objective-C? so confused...

so I have an array with objects @"One", "Two", "Three", "Mouse" and I want to have each word of the array NSLog'ed to the console in half second increments. I also would like to be able to switch to 1 second increments instead. Can anyone please help me write this code. I'm new, but I need to understand this project. I was tipped that I...

unknown array length in python ctypes

I'm calling a C function using ctypes from Python. It returns a pointer to a struct, in memory allocated by the library (the application calls another function to free it later). I'm having trouble figuring out how to massage the function call to fit with ctypes. The struct looks like: struct WLAN_INTERFACE_INFO_LIST { DWORD ...

PHP: simple array operation

Hey. I have an array like this (one dimension only): $arr = array('one', 'two', 'three', 'foo', 'bar', 'etc'); Now I need a for() loop that creates a new array from $arr, like that: $newArr = array('one', 'onetwo', 'onetwothree', 'onetwothreefoo', 'onetwothreefoobar', 'onetwothreefoobaretc'); Seems to be simple but I can't figur...

Jquery: How to get the value of an input and put in an array

I have an input <input type="text" value="hello" /> and I want to get the value of this and using Jquery, save the value in an array. How can I do this??? ...