I keep reading that, in C, using pointer arithmetic is generally faster than subscripting for array access. Is this true even with modern (supposedly-optimizing) compilers?
If so, is this still the case as I begin to move away from learning C into Objective-C and Cocoa on Macs? (As is the primary goal of my picking up C -- get enough th...
I have created a .NET DLL which makes some methods COM visible.
One method is problematic. It looks like this:
bool Foo(byte[] a, ref byte[] b, string c, ref string d)
VB6 gives a compile error when I attempt to call the method:
Function or interface marked as
restricted, or the function uses an
Automation type not supported ...
Which algorithm does the JavaScript Array.sort() function use? I understand that it can take all manner of arguments and functions to perform different kinds of sorts, I'm simply interested in which algorithm the vanilla sort uses.
...
What is most concise/efficient way to find out if a javascript array contains an obj?
This is the only way I know to do it:
contains(a, obj){
for(var i = 0; i < a.length; i++) {
if(a[i] === obj){
return true;
}
}
return false;
}
Is there a better/more concise way to accomplish this?
This is very closely related t...
I have an associative array in the form key => value where key is a numerical value, however it is not a sequential numerical value. The key is actually an ID number and the value is a count. This is fine for most instances, however I want a function that gets the human-readable name of the array and uses that for the key, without changi...
In Java, we can always use an array to store object reference. Then we have an ArrayList or HashTable which is automatically expandable to store objects. But does anyone know a native way to have an auto-expandable array of object references?
Edit: What I mean is I want to know if the Java API has some class with the ability to store re...
I have a key that appears to be an empty string, however using unset($array[""]); does not remove the key/value pair. I don't see another function that does what I want, so I'm guessing it's more complicated that just calling a function.
The line for the element on a print_r is [] => 1, which indicates to me that the key is the empty st...
I have a class which I'm serialising to send over a unix socket and it has to have a string which I've stored as a char array. Can I initialise it in the constructor differently to how I've done it here?
typedef struct SerialFunctionStatus_t {
SerialFunctionStatus_t()
: serial_rx_count(0), serial_tx_count(0), socket_rx_cou...
I recently read that using flexible array members in C was poor software engineering practice. However, that statement was not backed by any argument. Is this an accepted fact?
(Flexible array members are a C feature introduced in C99 whereby one can declare the last element to be an array of unspecified size. For example: )
struct hea...
Can someone explain how PHP implements associative arrays? What underlying data structure does PHP use? Does PHP hash the key and store it in some kind of hash map? I am curious because I was wondering what the performance of associative arrays where when inserting and searching for keys.
...
a:3:{i:0;i:4;i:1;i:3;i:2;i:2;}
Am I right to say that this is an array of size 3 where the key value pairs are 0->4, 1->3, and 2->2? If so, I find this representation awfully confusing. At first, I thought it was a listing of values (or the array contained {0, 4, 1, 3, 2, 2}), but I figured that the a:3: was the size of the array. And i...
I need to write an extension method on a byte[]. Is that possible?
...
Now that Java is open source, one of the first things I would like to do is to disable array bounds checking for certain blocks of code, where I'm dead sure I cannot go offbounds and where performance heavily matters.
Now, I'm not a compilers/grammar expert, so any syntax would be good enough for me: Here's one that I can think of:
pra...
How would I implement a binary search using just an array?
...
I have a CSV data file with rows that may have lots of columns 500+ and some with a lot less. I need to transpose it so that each row becomes a column in the output file. The problem is that the rows in the original file may not all have the same number of columns so when I try the transpose method of array I get an `transpose': elemen...
When you do the following in an HTML form:
<input name="one[]" value="foo" />
<input name="one[]" value="bar" />
<input name="two[key]" value="something" />
and submit the form to a PHP page, The $_POST array will look as follows:
array(
'one' => array(
0 => 'foo',
1 => 'bar'
),
'two' => array(
'ke...
Does anybody knows how can I get the max and min value of the 2nd and 3rd columns in PHP?
$ar = array(array(1, 10, 9.0, 'HELLO'),
array(1, 11, 12.9, 'HELLO'),
array(3, 12, 10.9, 'HELLO'));
Output should be like:
max(12.9)
min(10)
Thanks in advance
...
Lists in c# have the .toArray() function. I want the inverse, where an array is transformed into a list. I know how to create a list and loop through it but i would like a one liner to swap it back.
I am using the string.split function in the .NET 2.0 environment so Linq etc. is not available to me.
...
Using .Net how do I use the Sort method to sort an Array in reverse i.e. Z to A?
...
look at one of my header file which consists of a union template with 4 different structures.
<#define MAX 3
union family
{
struct name /*for taking the name and gender of original member*/
{
unsigned char *namess;
unsigned int gender;
union family *ptr_ancestor; /*this is a pointer to his ancestors detai...