How do I make an array shorter in Perl? I read some webpages indicating that I can assign:
$#ARRAY = 42;
I read that the use of $# is deprecated. I need a solution that will work for an array of arrays, too. This didn't work:
$#$ARRAY[$i] = 42;
...
I have huge 3D arrays of numbers in my .NET application. I need to convert them to a 1D array to pass it to a COM library. Is there a way to convert the array without making a copy of all the data?
I can do the conversion like this, but then I use twice the ammount of memory which is an issue in my application:
double[] result = new ...
Suppose I have a collection (be it an array, generic List, or whatever is the fastest solution to this problem) of a certain class, let's call it ClassFoo:
class ClassFoo
{
public string word;
public float score;
//... etc ...
}
Assume there's going to be like 50.000 items in the collection, all in memory.
Now I want to obtain as f...
Is there an easy way to do any of the following things in awk?
Sorting array/hash by it's data
Sorting a hash by it's string key
...
What's the most elegant way to select out objects in an array that are unique with respect to one or more attributes?
These objects are stored in ActiveRecord so using AR's methods would be fine too.
...
Which is the best way to store a 2D array in c# in order to optimize performance when performing lots of arithmetic on the elements in the array?
We have large (approx 1.5G) arrays, which for example we want to multiply with each other element by element. Performance is critical. The context in which this is done is in c#. Is there any ...
Given an Array of n Objects, let's say is an Array of Strings, and it has the following values:
foo[0]="a";
foo[1]="cc";
foo[2]="a";
foo[3]="dd";
What do I have to do to delete/remove all the Strings/Objects equal to "a" in the Array?
Thanks!
...
I'm having a hard time understanding and therefore managing arrays and indexes manually in C. These are my two classic approaches but they doesn't seem to work as they keep looping when the condition is reached:
#include<stdio.h>
#define MAX 255
int main(){
int arr[MAX]={0};
int idx=0;
/* Approach #1 */
printf("Ente...
I'm used to python, so this is a bit confusing to me. I'm trying to take in input, line-by-line, until a user inputs a certain number. The numbers will be stored in an array to apply some statistical maths to them. Currently, I have a main class, the stats classes, and an "reading" class.
Two Questions:
I can't seem to get the input l...
I have 2 arrays of 16 elements (chars) that I need to "compare" and see how many elements are equal between the two.
This routine is going to be used millions of times (a usual run is about 60 or 70 million times), so I need it to be as fast as possible. I'm working on C++ (C++Builder 2007, for the record)
Right now, I have a simple:
...
Given an array of integers, what is the simplest way to iterate over it and figure out all the ranges it covers? for example, for an array such as:
$numbers = array(1,3,4,5,6,8,11,12,14,15,16);
The ranges would be:
1,3-6,8,11-12,14-16
...
I currentyl have no clue on how to sort an array which contains UTF-8 encoded strings in PHP. The array comes from a LDAP server so sorting via a database (would be no problem) is no solution.
The following does not work on my windows development machine (although I'd think that this should be at least a possible solution):
$array=arra...
I am going through John Resig's excellent Advanced javascript tutorial and I do not thoroughly understand what's the difference between the following calls: (please note that 'arguments' is a builtin javascript word and is not exactly an array hence the hacking with the Array.slice instead of simply calling arguments.slice)
>>> argument...
just wondering what it is.
Edit: I know it's not a type of array but just a feature. So what does it mean by one-element-too-large ?
...
I'm looking for a simple, easy to understand algorithm to alphabetically sort an array of characters in C.
...
Been using PHP/MySQL for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using mysql_fetch_object() vs mysql_fetch_assoc() / mysql_fetch_array().
...
What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this.
$sortedObjectArary = sort($unsortedObjectArray, $Object->weight);
Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional array sorting and there might be something useful there...
.Net has a lot of complex data structures. Unfortunately, some of them are quite similar and I'm not always sure when to use one and when to use another. Most of my C# and VB books talk about them to a certain extent, but never really go into any real detail.
What's the difference between Array, ArrayList, List, Hashtable, Dictionary, S...
Hello.
I have recently been thinking of the difference between the two ways of defining an array:
int[] array
int array[]
Is there a difference? I havent found anything in my Java book explaining me the difference and googling the question isnt bringing me any closer... I just dont know what to google after.
Thanks
...
Hello all,
currently I'm dealing with a video processing software in which the picture data (8bit signed and unsigned) is stored in arrays of 16-aligned integers allocated as
__declspec(align(16)) int *pData = (__declspec(align(16)) int *)_mm_malloc(width*height*sizeof(int),16);
Generally, wouldn't it enable faster reading and writing...