arrays

How can I make this declaration work?

EDIT: I also got an answer to make sector a vector of vectors: vector<vector<char>>sector; and that gets rid of the rest of my errors. EDIT: I've made sector an array of pointers as someone suggested, and still get three errors: EDIT: I have edited the program, but it has not fixed all of the errors: I have this section of a progra...

C#, List<T>.Contains() - too slow?

Could anyone explain me why the generics list's Contains() function is so slow? I have a List with about a million numbers, and the code that is constantly checking if there's a specific number within these numbers. I tried doing the same thing using Dictionary and the ContainsKey() function, and it was about 10-20 times faster than with...

How do I store arrays in an STL list?

Using C++ and the STL, does anybody know how to store integer arrays as nodes in an STL list or vector? I have an unknown number of pairs of numbers that I need to store, and coming from other languages my first thought was to use some sort of list- or vector-like data structure... but I'm running into some trouble. I am 100% sure that I...

Length of an array of pointers

Hi, if I have an array of pointers like char **lines, how can i determine its length? Thanks ...

Max Size of .Net Arrays

Not that I would ever need to do this, but I want to understand how it works/doesnt work. I googled quite a bit for max length of an array and can't really find anything. long[] hugeArray = new long[long.MaxValue]; //No Exceptions Console.WriteLine("Init"); //Overflow Exception Console.WriteLine(hugeArray.LongLength.ToString()); huge...

Why is inserting at the end of a dynamic array O(1) while inserting in the middle is O(n)?

Accordingly to the Wikipedia article on dynamic arrays, inserting/deleting at the end of the array is O(1) while inserting/deleting from the middle is O(n). Why exactly is that? Also - if I have a dynamic array with 5 elements and I insert a new element at position 6 the operation is O(n) whereas if I use the function to append to the ...

PHP get all arguments as array?

Hey, I was working with a PHP function that takes multiple arguments and formats them. Currently, I'm working with something like this: function foo($a1 = null, $a2 = null, $a3 = null, $a4 = null){ if ($a1 !== null) doSomethingWith($a1, 1); if ($a2 !== null) doSomethingWith($a2, 2); if ($a3 !== null) doSomethingWith($a3, 3)...

What is so wrong with extract()?

Hey everyone, I was recently reading this thread, on some of the worst PHP practices. In the second answer there is a mini discussion on the use of extract(), and im just wondering what all the huff is about. I personally use it to chop up a given array such as $_GET or $_POST where I then sanitize the variables later, as they have bee...

C++ new[] into base class pointer crash on array access

When I allocate a single object, this code works fine. When I try to add array syntax, it segfaults. Why is this? My goal here is to hide from the outside world the fact that class c is using b objects internally. I have posted the program to codepad for you to play with. #include <iostream> using namespace std; // file 1 class a...

How to convert a sbyte[] to byte[] in C#?

I've got a function which fills an array of type sbyte[], and I need to pass this array to another function which accepts a parameter or type byte[]. Can I convert it nicely and quickly, without copying all the data or using unsafe magic? ...

Create an array using the index values from another array

OK here is what I would like to do. I have an array. What i want to do is make another array of the index values from the first one. Take the below I want to create and array from this : Array ( [identifier] => ID [label] => HouseNum [items] => Array ( [0] => Array ( ...

how do i pass multiple arguments to a ruby method as an array?

Hi All, I have a method in a rails helper file like this def table_for(collection, *args) options = args.extract_options! ... end and i want to be able to call this method like this args = [:name, :description, :start_date, :end_date] table_for(@things, args) so that I can dynamically pass in the arguments based on a form commit...

how to create a stored procedure in oracle which accepts array of parameters

Can any one tell me if its possible to create a stored procedure in oracle which accept array as an input parameter and how ? ...

How do I iterate rows and columns of a multidimensional array?

I would like to iterate the rows and columns separately on a two dimensional array: object[,] values; How would I iterate through just the rows and just the columns? ...

Natural sorting algorithm in PHP with support for Unicode?

Is it possible to sort an array with Unicode / UTF-8 characters in PHP using a natural order algorithm? For example (the order in this array is correctly ordered): $array = array ( 0 => 'Agile', 1 => 'Ágile', 2 => 'Àgile', 3 => 'Âgile', 4 => 'Ägile', 5 => 'Ãgile', 6 => 'Test', ); If I try with asort($array)...

How to loop through multiple arrays?

Hi, I'm new to this, so sorry if my question has been asked before. I have searched but have not been able to find, or perhaps recognise, an answer. I am using visual studio 2008 and creating an app in vb.net. I have 4 arrays named:- account1 account2 account3 account4. They all have 4 elements. I want to assign values to the elements i...

Reading from a stream not knowing how much to expect [c#]

How can I read from a stream when I don't know in advance how much data will come in? Right now I just picked a number on a high side (as in code below), but there's no guarantee I won't get more than that. So I read a byte at a time in a loop, resizing array each time? Sounds like too much resizing to be done :-/ TcpClient tcpclnt = n...

How much memory is allocated for each element when you dimension an array?

For instance, in VB.NET: Dim strArray(5) As String As I understand it, because this is an array, the computer will allocate contiguous memory locations for each of the 5 elements. But how much space is allocated for each of the five elements? What if I decide to put a 5MB block of text in position 2 of the array? Is it differen...

How to handle passing runtime-sized arrays between classes in C++

Right now I have a simple class that handles the parsing of XML files into ints that are useful to me. Looks something like this: int* DataParser::getInts(){ *objectNumbers = new int[getSize()]; for (int i=0;i<getSize();i++){ objectNumbers[i]=activeNode->GetNextChild()->GetContent(); } return objectNumbers; ...

Actionscript 3.0 Best Option for Subclassing Vector Class (Flash Player 10)

I would like to take advantage of all the goodness of the newer Vector class for FP10, but it seems it is marked as final. I am doing some intensive mathematical processing in Actionscript, and repeatedly process arrays of Numbers. I have previously been using my own subclass of Array(I call it NumericArray), with added functions such a...