arrays

IComparer problem + How do I sort an array of strings naturally (FILE_10 > FILE_2) in .NET?

SOLVED at the bottom of my post. Or more specifically: I have a bunch of FileInfo objects (I need the FileInfo objects to exclude hidden, system and reparse point files). I need to sort FileInfo[] naturally based on their FileInfo.FullName. So FILE_10.ext should come after FILE_2.ext. Luckily the FileInfo[] contains files of only one ...

How can I concatenate upper and lower nibbles stored sequentially in an array?

Hi friends, I have an array which contains a list of nibbles: {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, ...} I want to combine adjacent nibbles into single bytes by left-shifting the upper nibble and concatenating it with the lower one. The output should look as follows: {0xab, 0xcd, 0xef, ...} How can I accomplish this in C? ...

Array posting in PHP

I am trying to post an array full of checkboxes and to open it in the next page.. It only gives me the last result, anyone know why? or how to fix it? <form name="input" action="createevent.php" method="post"> Event title: <input type="text" name="Eventtitle" size="20"> <br>Event Description <input type="text" name="Description" siz...

Pulling Data from a Mysql Table Field and putting it into an array

I can find lots of tutorials showing you how to load an array into a database field but can't seem to figure out how to pull each entry in a field into an array as seperate items. Seems simple enough just can't get it to work, any help? ...

PHP: Holding two matching items in an array of data from MySQL

$story_query = "SELECT table_name, id FROM planning WHERE parent = '$novelnum'"; $story_result = db_query($story_query); while($story_row = db_fetch_array($story_result)) { $taleTable_Name = $story_row['table_name']; $postid[] = $story_row['id']; $q2 = "Select * from $taleTable_Name where approved='Y' order by id"; $bset...

Vertical to Horizontal?

Hi again, I have a PostgreSQL table that looks like this: A -> B A -> C A -> G A -> H B -> O B -> K Where "->" separates two columns where the first points to the second (hyperlinks). Now I would like to take all distinct values in the first column and assign them an ARRAY containing all values to which they point to in the second co...

Python: Numpy array help. Is there a function to return the index of something in an array?

I know there is a method for python list to return the first index of something l = list(1,2,3) l.index(2) >>> 1 Is there something like that for numpy arrays? Thanks for your help :) ...

How to implement dynamic arrays in Delphi

I originally had an array[1..1000] that was defined as a global variable. But now I need that to be n, not 1000 and I don't find out n until later. I know what n is before I fill the array up but I need it to be global therefore need a way to define the size of a global array at run time. Context is filling an array with a linear transf...

PHP: Convert a String to Variable

I've got a multidimensional associative array which includes an elements like $data["status"] $data["response"]["url"] $data["entry"]["0"]["text"] I've got a strings like: $string = 'data["status"]'; $string = 'data["response"]["url"]'; $string = 'data["entry"]["0"]["text"]'; How can I convert the strings into a variable to access ...

Array of structs and new / delete

I have a struct like this: class Items { private: struct item { unsigned int a, b, c; }; item* items[MAX_ITEMS]; } Say I wanted to 'delete' an item, like so: items[5] = NULL; And I created a new item on that same spot later: items[5] = new item; Would I still need to call delete[] to clean this up? Or won't this be needed...

Array versus List<T>: When to use which?

MyClass[] array; List<MyClass> list; What are the scenarios when one is preferable over the other? And why? ...

How to design this method if it returns multi-dimensional arrays?

I am now designing an SNMP library. The problem is caused by a special function like this, *** GetTable(string id) This function may return Variable[,] which is a two dimensional array sometimes, but also Variable[,,] and arrays with more dimensions. So I believe it is not reasonable to return fixed array such as Variable[,], Variable[...

PHP Arrays, appending depth of array item recursively to an array with the key of 'depth'

Per the example array at the very bottom, i want to be able to append the depth of each embedded array inside of the array. for example: array ( 53 => array ( 'title' => 'Home', 'path' => '', 'type' => '118', 'pid' => 52, 'hasChildren' => 0, ), Has a depth of one accordin...

Can someone explain this template code that gives me the size of an array?

template<typename T, size_t n> size_t array_size(const T (&)[n]) { return n; } The part that I don't get is the parameters for this template function. What happens with the array when I pass it through there that gives n as the number of elements in the array? ...

How do I print unique elements in Perl array?

I'm pushing elements into an array during a while statement. Each element is a teacher's name. There ends up being duplicate teacher names in the array when the loop finishes. Sometimes they are not right next to each other in the array, sometimes they are. How can I print only the unique values in that array after its finished getting...

Java sort String array of file names by their extension

I have an array of filenames and need to sort that array by the extensions of the filename. Is there an easy way to do this? ...

Retruning a variable sized array of doubles from C++ to C# - a simpler way ?

I have the following C++ method : __declspec(dllexport) void __stdcall getDoubles(int *count, double **values); the method allocates and fills an array of double and sets *count to the size of the array. The only way i managed to get this to work via pinvoke is : [System.Runtime.InteropServices.DllImportAttribute("xx.dll")] public s...

Arrays as result type and input for functions

in delphi7 i have a function that i need to return a array as a result type b "function createsbox(key:tkey):array[0..255] of byte;" this is not allowed it is expecting a "identifyer expected but array found" is the error throw up. seems to work fine if i declare a record type of array but it seems pointless to do this for one function....

Indexing arrays with enums in C#

I have a lot of fixed-size collections of numbers where each entry can be accessed with a constant. Naturally this seems to point to arrays and enums: enum StatType { Foo = 0, Bar // ... } float[] stats = new float[...]; stats[StatType.Foo] = 1.23f; The problem with this is of course that you cannot use an enum to index a...

Passing an array as a function parameter in C++

In C++, arrays cannot be passed simply as parameters. Meaning if I create a function like so: void doSomething(char charArray[]) { // if I want the array size int size = sizeof(charArray); // NO GOOD, will always get 4 (as in 4 bytes in the pointer) } I have no way of knowing how big the array is, since I have only a point...