I have a 2-dimensional jagged array (though it's always rectangular), which I initialize using the traditional loop:
var myArr = new double[rowCount][];
for (int i = 0; i < rowCount; i++) {
myArr[i] = new double[colCount];
}
I thought maybe some LINQ function would give me an elegant way to do this in one statement. However, the c...
C++ has std::vector and Java has ArrayList, and many other languages have their own form of dynamically allocated array. When a dynamic array runs out of space, it gets reallocated into a larger area and the old values are copied into the new array. A question central to the performance of such an array is how fast the array grows in siz...
Hi all,
I'm looking for a method that will return a section or segment of an array - like if I wanted only the 4th and 5th bytes of a byte array. I don't want to have to create a new byte array in the heap memory just to do that. Right now I have the following code:
doSomethingWithTwoBytes(byte[] twoByteArray);
void someMethod(byte[...
Hello,
I'm making a hit counter. I have a database and I store the IP and $_SERVER['HTTP_USER_AGENT']; of the visitors. Now I need to add a filter, so I can put away the hits, that are made by bots. I found out, that many bots usually keep some common words in the $_SERVER['HTTP_USER_AGENT']; , so I's like to make and array of words, th...
Hi,
I'm trying to query a MySQL database using an array but I'm having trouble!
I have a table called clients, I want to be able to select 'name' from all rows whose 'sector' column is equal to $sectorlink.
I then want to put all the names into an array so I can perform my next query: select all rows from another table whose 'client...
I'm always struggling with generics. I don't know why this makes my go crazy. I have an old problem I've got several times.
class Father {
...
}
class Child1 extends Father {
...
}
class Child2 extends Father {
...
}
public class TestClass {
private static Class<? extends Father>[] myNiceClasses = new Class<? extends ...
Consider the following code fragment in VS2010 Beta 1:
let array = Array2D.zeroCreate 1000 500
This produces an error, namely:
error FS0030: Value restriction. The value 'array' has been inferred to have
generic type val array : '_a [,]
Either define 'array' as a simple data term, make it a function with explicit
arguments or, i...
If I have an array as $keys => $values, how can I get two arrays of $keys and $values?
...
Is there an easy way to sort an NSMutableArray of NSMutableArrays containing NSStrings?
I am sure that there must be an easy method for doing this but I can't seem to find it.
To Clarify I want to sort the first array alphabetically by the NSString at index 3 of the sub array.
...
As far as i know, the result of
["a", "A"].uniq
is
["a", "A"]
My question is:
How do I make ["a", "A"].uniq give me either ["a"] or ["A"]
...
I have a problem where a couple 3 dimensional arrays allocate a huge amount of memory and the program sometimes needs to replace them with bigger/smaller ones and throws an OutOfMemoryException.
Example: there are 5 allocated 96MB arrays (200x200x200, 12 bytes of data in each entry) and the program needs to replace them with 210x210x210...
Hello,
I have this array:
Array
(
[1] => animal
[1-1] => turtle
[1-1-1] => sea turtle
[1-1-2] => box turtle
[1-1-3] => green turtle
[1-1-3-1] => green turtle with brown tail
)
and I want some how to convert it into:
Array
(
[1-title] => animal
[1-sons] => array(
[1-1-title] => turtle
...
I'm trying to use reflection to call a method that takes in a byte array.
I'm starting off doing:
Class myClass = anObject.getClass();
Class[] parameterTypes =
{byte[].getClass();};
But that doesn't work (class expected, } expected) on the byte[] line. Anyone know what I should do? Cast to an Object and declare that the method tak...
Hi, I have searched on here for a quality method to compare associative arrays in javascript. The only decent solution I have found is the PHP.JS project which has some comparative array functions. The only problem is that these functions consider the first array as the key to the second. In my situation at least both arrays do not alway...
So lets say I've added some prototype methods to the Array class:
Array.prototype.containsKey = function(obj) {
for(var key in this)
if (key == obj) return true;
return false;
}
Array.prototype.containsValue = function(obj) {
for(var key in this)
if (this[key] == obj) return true;
return false;
}
t...
What's the nicest way to convert a Vector to an Array in Actionscript3?
The normal casting syntax doesn't work:
var myVector:Vector.<Foo> = new Vector();
var myArray:Array = Array(myVector); // calls the top-level function Array()
due to the existance of the Array function. The above results in an array, but it's an array with a sin...
Hi,
I'm just starting to teach myself objective-c and attempting to learn the cocoa touch frameworks, as like many people recently I have developed an interested in a certain little multi-touch device.
Anyway, I'm following the Stanford tutorials and I have couple of Objective-C books that im starting to make my way through. While comp...
I am currently using the following code for Get variables, and would like to know the best way to convert to an array. Is the main advantage of doing this just aesthetic, or is there a performance/efficiency aspect as well?
if (isset($_GET["cmd"]))
$cmd = $_GET["cmd"];
else
die("Invalid URL");
if (isset($_GET["username"]))
{ $usern...
I have an issue with php where code works on on computer but wont work on another
function appendParam(&$req, $name, $value) {
if (req == null) {
return;
}
if (name == null) {
return;
}
if (value != null) {
$req[$name] = $value;
}
}
The above works on one computer and is capable of checking req and name against null pr...
I have an array:
Array
(
[1] => 25
[2] => 50
[3] => 25
)
I would like to make it into:
Array
(
[1] => 50
[2] => 50
)
To do this I split the middle value between 1 and 3. This is the simplest example, where the split is 50,50. I would like to be able to take a 15 element array down to 6 elements.
Any ideas?
Add...