jagged-arrays

How to iterate a jagged array?

This has been driving me crazy for a few days. Why doesn't the following work? Dim arr(3, 3) As Integer For y As Integer = 0 To arr.GetLength(0) - 1 For x As Integer = 0 To arr.GetLength(y) - 1 arr(y, x) = y + x Next Next Also, what if the array looked like this instead? { {1, 2, 3}, {4, ...

reading from a text file into a jagged array

I found this question in an old question in your website so i thought i can do it but I think I was mistaken :-) the old post was here I'm new at the jagged array thing so did the following code StreamReader rows = new StreamReader("c:\\practice.txt"); string line; int i; i=1; while ((li...

Converting from a jagged array to double pointer in C#

Simple question here: is there any way to convert from a jagged array to a double pointer? e.g. Convert a double[][] to double** This can't be done just by casting unfortunately (as it can in plain old C), unfortunately. Using a fixed statement doesn't seem to resolve the problem either. Is there any (preferably as efficient as possib...

How can I model this Jagged data?

I am in charge of modeling a 3 floor warehouse, where boxes of documents will be stored. There are rows, columns and shelves in the equation. in addition: some floor/row/column/shelf combinations store 2 boxes, some 3. some rows don't have the normal amount of columns. They want my application to auto-increment to print labels (20 ...

jagged array in c

Is there such a thing as a jagged array in C or C++? When I compile this: int jagged[][] = { {0,1}, {1,2,3} }; I get this error: error: declaration of `jagged' as multidimensional array must have bounds for all dimensions except the first ...

Initialize a Jagged Array the LINQ Way

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...

Flex: Convert ArrayCollection to jagged String Array

Is there any built in functionality to convert an ArrayCollection to a jagged string array? I have an Arraycollection of objectproxies that I get from a SOAP webservice (asp.net datatable) that I modify and want to send back. Thanks, Brian ...

C : Problem with Jagged Arrays

I have the following code : int *edges[500]; char arr[] = {'c','d'}; edges[0] = arr; printf("%c - %c", edges[0][0],edges[0][1]); What I want displayed is c - d but what is actually being displayed is c - So as you can see above, the first element is being displayed but not the second one. Why isn't the second element of the array ...

How does C# 3.0 jagged array performance optimization vs. rectangular arrays work ?

Hi, In the Apress book "Illustrated C# 2008", pg. 343 notes: "One-dimensional arrays have specific instructions in the CIL that allow them to be optimized for performance. Rectangular arrays do not have these instructions...Because of this, it can sometimes be more efficient to use jagged arrays..." Does anyone know how these pe...

Parse jagged array in C#

I'm connecting to an external web service that is implemented using Apache Axis and SOAP 1.2. The web service returns a jagged object array like the one below. Looking at the XML the I have xsi:type="soapenc:Array" What would be the cleanest/best method of parsing this array in C#2 and C#3 respectively? (I'm specifically interested in C...

C# Battleships Class/Structure

greetings, im am new to programming and at the moment developing a clone of the game battleships. i need to implement a fleet of 5 ships. this is what i have done so far: class Cell holds the status of a table cell: public class Cell { // class for holding cell status information public enum cellState { WATER, ...

ASP.NET looping through jagged array stored in session

hey all, im having some problems with jagged arrays stored in session for ASP.net i have some code which creates a jagged array, them populates, and then stores this populated jagged array into session protected string[][] answersJArray; answersJArray[0] = new string[4]("test","test1","test2","test3"}; answersJArray[1] = new string[...

Avoiding Agnostic Jagged Array Flattening in Powershell

Hello, I'm running into an interesting problem in Powershell, and haven't been able to find a solution to it. When I google (and find things like this post), nothing quite as involved as what I'm trying to do comes up, so I thought I'd post the question here. The problem has to do with multidimensional arrays with an outer array length...

How should I map multidimensional to jagged arrays?

I'd like to map Foo[,] to Foo[][] and back. There are simple solutions using loops, but isn't there something more elegant? In my specific case, this is required in this scenario: [DataContract] class A { // can't serialize this thingy private readonly Foo[,] _Foo; [DataMember] private Foo[][] SerializableFoo { ...

Copy one jagged array ontop of another.

How could I accomplish copying one jagged array to another? For instance, I have a 5x7 array of: 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0 and a 4x3 array of: 0,1,1,0 1,1,1,1 0,1,1,0 I would like to be able to specify a specific start point such as (1,1) on my all zero arra...

How to find unique values in jagged array

I would like to know how I can count the number of unique values in a jagged array. My domain object contains a string property that has space delimitered values. class MyObject { string MyProperty; //e.g = "v1 v2 v3" } Given a list of MyObject's how can I determine the number of unique values? The following linq code returns an...

c# Wrapper to native c++ code, wrapping a parameter which is a pointer to an array

Hi, I have the following simple DLL in c++ un-managed code; extern "C" __declspec(dllexport) void ArrayMultiplier(float (*pointerArray)[3], int scalar, int length); void ArrayMultiplier(float (*pointerArray)[3], int scalar, int length) { for (int i = 0 ; i < length ; length++) { for (int j = 0; j < 3; j++) { ...

Why doesn't negative values for the second index in a jagged array work in Python?

For example, if I have the following (data from Project Euler): s = [[75], [95, 64], [17, 47, 82], [18, 35, 87, 10], [20, 4, 82, 47, 65], [19, 1, 23, 75, 3, 34], [88, 2, 77, 73, 7, 63, 67], [99, 65, 4, 28, 6, 16, 70, 92], [41, 41, 26, 56, 83, 40, 80, 70, 33], [41, 48, 72, 33, 47, 32, 37, 16, ...

How to create multi-dimensional jagged arrays in VbScript ?

I need to create multi-dimensional array of strings. Each row of the array can have varying number of strings. Something like the follwing code: twoDimension = Array(Array()) ReDim Preserve twoDimension(3) For i = 0 to 2 If i = 1 Then twoDimension(i) = Array(1,2,3) End If If i = 2Then twoDimension(i) = Array(1,...

Jagged Array Dimensions

I'm using jagged arrays and have a bit of a problem (or at least I think I do). The size of these arrays are determined by how many rows are returned in a database, so it is very variable. The only solution I have is to set the dimensions of the array to be very huge, but this seems ... just not the best way to do things. int[][] hul...