arrays

How can I improve on this. (Breadcrumbs class)

Hi, I have recently created a breadcrumbs class that fits in with our in-house CMS and it works as I intend but I have a nagging feeling it could have been done better. I was thinking of doing an array_pop close to the end of the construct but I decided to go with an IF statement instead, what do you guys think? (Oh also $_REQUEST['sec...

How to sort C++ array in ASC and DESC mode?

Hi, I have this array: array[0] = 18; array[1] = -10; array[2] = 2; array[3] = 4; array[4] = 6; array[5] = -12; array[6] = -8; array[7] = -6; array[8] = 4; array[9] = 13; how do I sort the array in asc/desc mode in C++? ...

Implementation of extremely sparse arrays

I have an extremely sparse static array with 4 dimensions of 8192 each that I want to do lookups from (C#). Only 68796 of these 4.5 * 10^15 values are non-zero. What is the fastest way to do this, with speed and low memory usage being vital? Thanks ...

Error CS1501: I'm not overloading a Sum() method correctly

Below is draft number 5 for my C# Homework this week. I wrote the program out using Linq first, and it worked fine. Unfortunately, the directions state that I must create my own method instead of using the wonderful Sum() method already found in Linq. The major problem with this source code is that the method overload is incorrect (and i...

Add character a place in String

Hi I'm trying to make a method that shall help me to spell world right. After addChar have return its work based on the input "famili", I want the result array to contain the word "familiy". Now the method removes a character from the string and replace it with the current char in alpha[], can someone please give me some help to make th...

Merge of 2 active record arrays very slow?

I have 2 sets of data as following: default_products - A set of active record objects retrieved from memcached owned_products - A set of active record objects retrieved from the database Retrieving the data is fast and i get around 30-40 req/s when just returning either one of the arrays yet as soon as i do the following to return both...

Joining arrays of hashes in Ruby

Hi. I am trying to join multiple arrays of hashes in ruby using a common key. For example: country_info = [ {country_id: "US", country_desc: "United States"}, {country_id: "AU", country_desc: "Australia"} ] country_stats = [ {country_id:"US", pageviews: 150}, {country_id:"AU", pageviews: 200} ] i_want = [ {country_id: "US",...

Java: T obj; type of obj.getClass() is Class<?> and not Class<? extends T>. why?

In such a function: <T> void foo(T obj) The type of obj.getClass() is Class<?> and not Class<? extends T>. Why? The following code works fine: String foo = ""; Class<? extends String> fooClass = foo.getClass(); So the signature of T#getClass() seems to return a Class<? extends T>, right? Why is the signature different if T really...

placement new + array +alignment

SomeObj<unsigned int>* Buffer; char* BufferPtr = MemoryManager::giveMeSomeBytes(resX*resY*sizeof(SomeObj<unsigned int>)); Buffer = new(BufferPtr) SomeObj<unsigned int>[resX*resY]; when I step past these lines with the debugger, it shows me the values for the variables Buffer and BufferPtr: BufferPtr: 0x0d7f004c Buffer: 0x0d7f0050 ...

Swapping two items in a javascript array

Possible Duplicate: Javascript swap array elements I have a array like this: this.myArray = [0,1,2,3,4,5,6,7,8,9]; Now what I want to do is, swap positions of two items give their positions. For example, i want to swap item 4 (which is 3) with item 8 (which is 7) Which should result in: this.myArray = [0,1,2,7,4,5,6,3,8,9]...

create dynamic array with jquery.

Hi guys. I need some help regarding jquery arrays. var queryArr; $(markersArray).each(function(index) { var _locationId = index; var _locName = markersArray[index].name; var _markerLat = markersArray[index].marker.getLatLng().lat(); var _markerLng = markersArray[index].marker.getLatLng().lng(); //I DO NOT ...

C arrays in objective C

I'm new to obj-c and I'm used to creating a property declaration for all my member vars and synthesizing them, just got the hang of it in fact. Along comes a need for a simple C array of a struct I typedeffed myself (I guess the struct aspect doesn't really matter). Can someone explain what I should be doing with this C array as far as...

difficulty modifying two dimensional ruby array

Hi there, Excuse the newbie question. I'm trying to create a two dimensional array in ruby, and initialise all its values to 1. My code is creating the two dimensional array just fine, but fails to modify any of its values. Can anyone explain what I'm doing wrong? def mda(width,height) #make a two dimensional array a = Ar...

Creating generic arrays in Java

public K[] toArray() { K[] result = (K[])new Object[this.size()]; int index = 0; for(K k : this) result[index++] = k; return result; } This code does not seem to work, it will through out an exception: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to ... Could someone tell me how I can ...

PHP: Array acting strangely in foreach

Hi, I have a class that is query data via a SOAP client. the results of the query are returned as an array of objects. Something strange is happening. I'm not sure if it only occurs when there is one element in the array. Here is the code: function getNotes($ticketid){ $ticketid = $this->ms_escape_string($ticketid); $conn ...

C# Call function in a class from another class

I'll start of by saying I'm not a developer. Yes this is a c# nightmare. But this is a one time tool and thats it. Quick and Dirty it just needs to work and thats it. I have the following code: public string[] get_status(string local_fname) { var dts_doc = new HtmlAgilityPack.HtmlDocument(); dts_doc.Load(...

best way to check a empty array?

hello! how can i check a array recursively of empty content like this example Array ( [product_data] => Array ( [0] => Array ( [title] => [description] => [price] => ) ) [product_data] => Array ( ...

Is there a 'shorter' way to define a list of e.g. 100 new arrays?

Hi all, my aim is to compare the first names with the title of an img-element and insert the last name when the first name matches the title of the img-element. But before programming it, I'd like to ask you a question. Is there an easier way to create a new array list containing the first and the last name than I've chosen? It would b...

PHP custom ordering array

An array arrives with some or all of the following values, in any order. What's the best way to order them in ascending size order? So starting with small and ending with XXL. I can usort but am a bit lost as to how the elements should be ordered in my user defined function Small XXL Medium Large XL EDIT: left out some info so create...

Accessing/modifying an array of strings in a structure

Suppose I have the following code: typedef struct { char **p; } STRUCT; int main() { STRUCT s; *(s.p) = "hello"; printf("%s\n", *(s.p)); return 0; } which obviously doesn't work, but it should show what I want to do. How would I go about initialising, accessing, printing, etc the array of strings in the structure...