Questions tagged [jagged-arrays]

A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." Use for questions about such arrays. If the array is multidimensional with all elements in each dimension being equal(eg: all rows have the same length), use [multidimensional-arrays] instead.

Filter by
Sorted by
Tagged with
0 votes
2 answers
44 views

Initializing Jagged Array with the same non-default value

I am trying to create a jagged array of 10 by 10 using Linq and I want to populate it (for now) all with the same letter (not character). However, I am having trouble figuring out how to populate it ...
moshesilver's user avatar
-2 votes
0 answers
57 views

I want to store matrices, and heterogeneous array in the same variable or file in python. Which is the best format for this data? [duplicate]

I am using pyvoro https://github.com/joe-jordan/pyvoro. Lets say pyvoro creates 'n' objects. Each object has 3 variables called vertices, faces, adjacency. Vertices and adjacency are rectangular ...
Mr Thomas Anderson's user avatar
0 votes
3 answers
74 views

How can I construct a jagged array from a select result from a SQL database?

I want to create a jagged array as follows: string[][] jaggedarray = { new string[ ] {"1","fred", "test1", "test2", "test3", "test4"}...
Luci's user avatar
  • 31
0 votes
2 answers
61 views

print common elements between two arrays from jagged array and multidimensional array

int[][] arr1 = new int[][] {{1,2,1},{9,7,2},{7,3,6}}; int arr2[][] = new int[][] {{2,6,8},{0,1,7},{7,2,0},{8,3}}; boolean duplicate= false; for(int i=0;i<arr1.length;i++) { ...
Akshitha's user avatar
1 vote
1 answer
45 views

How can i declare a multi dimensional array in Powershell?

I have an array as follows: $apps = @('app1', 'app1a', 'app1b', 'app2', 'app2a', 'app2b') Now app1 , app1a and app1b are all related, so I want them in one item in the array and able to access: I ...
Traci's user avatar
  • 73
0 votes
0 answers
47 views

How to write Jagged array into shared memory with C/C++

I have the following jagged array (rank 6) which is output of a C/C++ code (this is achieved by splitting a rectangular 2D array) {{{{{{1270529, 1, 1, 1, 1, 0, 1, 0.05, 1, 0., 0.}, {0., 0., 0., 0., 0.,...
csk 7's user avatar
  • 101
0 votes
0 answers
32 views

How to shallow copy and deep copy a jagged array using ToArray()?

int[] nm = Array.ConvertAll(Console.ReadLine().Split(),int.Parse); int[][]graph = new int[nm[0]][]; int[][] meltedGraph = new int[nm[0]][]; for (int i = 0; i < nm[0]; i++) { graph[i] = Array....
Mint's user avatar
  • 1
-3 votes
1 answer
62 views

Allocating Jagged Array C#

It seems like there is no good way to allocate a jagged array in C#. It takes several orders of magnitude longer to allocate a jagged array than to allocate a 2D array. Is there any way around this? ...
Major Major's user avatar
1 vote
1 answer
59 views

C# generics error when overriding with an array?

I've written an abstract method in C# (/Unity however I don't think that's the issue here) that I want to use to export objects using generic types. The problem i'm facing is it wont allow me to ...
Lachlan Richards's user avatar
10 votes
0 answers
143 views

Issues with nullable reference types for arrays of arrays

Of course, C# supports unidimensional and multidimensional arrays, and supports arrays of arrays. Famously, if, in an array of arrays, the inner array type has a different rank (dimension count) than ...
Jeppe Stig Nielsen's user avatar
-1 votes
1 answer
56 views

Jagged Array is always empty [duplicate]

I can't seem to figure out why item within a List is not being appended to a Jagged Array. I have the following code var list = new List<(double,double)>{ ( -99.8299313,...
KJSR's user avatar
  • 1,719
-7 votes
1 answer
126 views

Array of arrays "newing" syntax is backwards?

In C#, when you "new" an array, it looks like this: int[] someArray = new int[5]; Which I read as: int-array someArray = new int-array-of-size-5 Today I casually tried to create an array ...
Clonkex's user avatar
  • 3,464
0 votes
3 answers
54 views

Assigning members of a list of list to a 2D array in C# [duplicate]

I create a list of list: List<List<string>> C = new List<List<string>>(); Then assign some values to it. Assume the assignment is as follows: List<...
Siha's user avatar
  • 47
-2 votes
2 answers
53 views

Converting int[][] to List<List<int>> [duplicate]

I need to convert an array int[][] to List<List<int>>. Is it possible and how? Array[index].Length can be 0. First, i tried to do like this: List<List<int>> ListName = new List&...
Umicron's user avatar
  • 17
0 votes
1 answer
96 views

How do I access properties of nested arrays in powershell within foreach loops?

I'm trying to write a script that checks whether a group of registry keys are set individually and then either sets them or modifies them conditional on thier current state. The keys that I want to ...
Rokos_Modern_Basilisk's user avatar
0 votes
1 answer
31 views

How to find certain target in jagged array with C#

So I set up jagged arrays and got the question from the user. Have finished setting up the target value based on the user's answer. But cannot show the boolean value whether the target value is in the ...
Wonjun Seo's user avatar
-1 votes
1 answer
93 views

C# How to sort a jagged array by index

I want to sort a jagged array by following condition: if array[i][0] != array[j][0], compare by array[i][0] - array[j][0] if array[i][0] != array[j][0], compare by i - j i, j is index of array Here ...
hpstory's user avatar
  • 25
1 vote
1 answer
50 views

how to add new field in a 'zip' jagged array

I want to add a new field in an already zipped jagged array. For example, if I zip 4D info into a muons object, then I can call pt,eta,phi,charge like this: muons.Muon.pt. However, if I want to add a ...
Zhenxuan's user avatar
0 votes
2 answers
111 views

Jagged array of multidimensionnal array int types

I'm now learning C# and making a couple of challenges, i managed to pass easily most of them but sometimes there are things i don't understand (i'm a python dev basically)... Create a function that ...
Garbez François's user avatar
0 votes
0 answers
32 views

How to create jagged arrays which consist of 3 number of arrays (i.e. Arrays of arrays of arrays )?

I want to create Boxes in a 3-dimensional grid. To create the same, I stored the number of x,y and z elements in each array and iterated to produce boxes in 3D grid. C# ScriptError message I expected ...
mk95's user avatar
  • 1
-2 votes
3 answers
287 views

How I can implement a 2-dimensional array with different column sizes dynamically?

How I can implement a 2-dimensional array with different column sizes dynamically in C? I tried many ways to implement a 2-dimensional array dynamically with different column sizes in c but I can't ...
Hemanth kumar's user avatar
1 vote
1 answer
468 views

How to pipe results into output array

After playing around with some powershell script for a while i was wondering if there is a version of this without using c#. It feels like i am missing some information on how to pipe things properly. ...
Dbl's user avatar
  • 5,694
0 votes
1 answer
69 views

C# - copying from a jagged array to a jagged array with data changes

I want to take the phrases that are stored in jagged array number one to break those phrases into individual words and put them into another jagged array. how to make it work? I was able to put the ...
Volodymyr's user avatar
0 votes
0 answers
72 views

Jagged Array ArrayIndexOutOfBounds

I have the following code to produce a jagged array as vertical columns, however, when it gets to the second set of numbers, it says it is out of bounds. Why is this? this is the code in question. ...
Sanallan's user avatar
0 votes
2 answers
60 views

Accesse to jagged arrays in different classes - C#

I had to model a system (a library) using jagged arrays. Each Physical Book must be on a shelf. A Bookshelf is an array of shelves. A Catalog is an array of bookshelves. Therefore, a Catalog "is ...
claudioclaudio's user avatar
1 vote
1 answer
196 views

PowerShell array, loop first row

I have a problem with array as following with only one line: $list = @() $list = (("ResourceGroup","Vm1")) $list | ForEach-Object -Parallel { write-output $_[0] $_[1] } If ...
Emanuele's user avatar
  • 193
0 votes
0 answers
25 views

I get garbage value on this jagged array

I get garbage value on this jagged array, that takes input size from another array's last value which must be -111(if not ten add one index to put in -111). i know i have missed some cout statements ...
Ahmad Bilal's user avatar
0 votes
0 answers
48 views

Unpacking a variable number of 2D jagged numpy tuples (findcontours())

I'm using cv2.findcontours() which outputs a variable number of variable length Nx2 tuples. For example, converting the tuples to a list: (array([[[100, 100]], ..., [[200, 200]]], dtype=int32), ...
Bob Bobinson's user avatar
1 vote
2 answers
59 views

Grouping arrays and 2D arrays into a single 2D array with the same length for all

The final result must always contain 6 values in each index: [ [value_1,value_2,value_3,value_4,value_5,value_6], [value_1,value_2,value_3,value_4,value_5,value_6] ] Position of the values: ...
Digital Farmer's user avatar
2 votes
3 answers
434 views

How define jagged array in python

Jagged array : A multidimensional array that has lines of varying length I also use C # cinnamon tooth arrays in Python. Is it possible? int[][] jaggedArray = new int[3][]; jaggedArray[0] = new int[5]...
shamim-shzd's user avatar
-3 votes
1 answer
57 views

How to access and use data from an array I guess? In C#

This is my first post... sorry in advance ... Hope you got mercy and I am not failing in "not enough code to help" - alright then here we go. I want to calculate the "by price the ...
Weltenwanderer's user avatar
0 votes
1 answer
103 views

C#: Shift given rows of jagged array to the top

I make a tetris game where i need to clear lines. I collect the full rows and make them empty by doing: for (var i = 0; i < playingGrid.Length; i++) //get rows { if (!playingGrid[i]....
Dave Nieberg's user avatar
0 votes
1 answer
101 views

Is there any way to speed up array initialization?

I have a function that stores values inside some arrays. Every time the function is called, the arrays have to be cleared before putting items in them. public static void UpdateAttackedPieces() { ...
Elia Giaccardi Old's user avatar
1 vote
1 answer
468 views

How do I make an array of arrays? or list of arrays in powershell?

$Colors = @{ 1 = 'White' 2 = 'Black' 3 = 'DarkBlue' 4 = 'DarkGreen' 5 = 'DarkCyan' 6 = 'DarkRed' ...
I am Jakoby's user avatar
1 vote
0 answers
176 views

Reading text file into jagged array

I'm trying to practice reading text files into a multidimensional object array, and I can't seem to figure out how to do that. The text file I have contains the days of the week, the number of flights ...
PatchPatch's user avatar
0 votes
1 answer
65 views

Numpy - Product of Cartesian Product Along Last Axis of Jagged Array

Given a nested list with unequal number of elements, I would like to find the fastest way to calculate the product of the cartesian product along the last axis. In other words, first calculate the ...
Flow Nuwen's user avatar
0 votes
0 answers
163 views

VBA Pass Array of Array from Function to another Function

I have defined the following data structures: Option Explicit Option Base 1 'Data related to coupon ---> these are the attributes Public Type CpnData 'coupon info cpn_no_prime As Integer ...
e_conomics's user avatar
0 votes
1 answer
132 views

2D Jagged array size change in c#

enter image description hereI am planning to calculate 3d coordinate points using vector3d. To find segmented points for a circle I thought i need to use jagged array to find the points. Can we change ...
Siddhu Gopi's user avatar
1 vote
1 answer
326 views

Excel VBA: Resize sub arrays within an array of arrays without declaring variable for each sub array

I have a tab delimited 2-dimensional data (copied from another Excel file on a remote system) in clipboard, which contains about 20 columns and can contain any number of rows. I want to read the data ...
AllSolutions's user avatar
  • 1,194
-1 votes
1 answer
42 views

how to create 2D using two different array or single array

I want output like this: items = [['red', 'blue', 'green'], ['small', 'medium', 'large']] I have array item which has value: items = ['red', 'blue', 'green','small', 'medium', 'large']
Junaid Shaikh's user avatar
0 votes
2 answers
221 views

From string to jagged array of chars

Without using LINQ, how can I approach this issue? I have a string: string stringContent = "Loremipsumdolorsitamet"; and the size of rows (max columns): int arraySize = 5; and then I have to ...
Linascts's user avatar
  • 159
3 votes
2 answers
568 views

Use c# `Index` and `Range` with jagged arrays

I am trying to use Index and Range objects to slice a jagged array. But in the example below I cannot extract columns, only rows. var A = new float[3][]; A[0] = new float[] { 1.1f, 1.2f, 1.3f }; A[1] ...
John Alexiou's user avatar
  • 28.7k
0 votes
0 answers
188 views

Pass C# simple struct Jagged Array (array of arrays) to C++ DLL

I have a third-party C++ DLL, that came with its header file as API. I want to be able to call one of its functions. The C++ header file looks like this: #ifdef __cplusplus extern "C" { #...
Eran.G's user avatar
  • 89
1 vote
2 answers
278 views

I'm confused about jagged arrays. I'm trying to make a for loop while accessing, print or change elements. How can I do this?

This is what I have so far. I'm trying to access and change the values int[][] numbers = new int[][]{ //giving the values... new int[]{4,5,6,7}, new int[]{6,88,9}, new int[]{4} }; for (i = 1; i <= ...
Allen Dario's user avatar
1 vote
4 answers
220 views

How to declare a 2d array whose rows vary in length in Julia?

I want to declare a 2d array which takes the form of zigzag shape as follows: *** ************ ****** * * ** where each star denotes an integer. This means that the lengths of its rows differ top to ...
roy.atlas's user avatar
  • 411
0 votes
1 answer
151 views

How to check for overlaps and continue to count sum for the unaccounted elements moving forward (jagged array)

For example I have this array in which later I would need to search through: private static readonly decimal[] ArrayWithFiveElements = { 0.1m, 0.2m, 0.3m, 0.4m, 0.5m }; And then I have a arrays of ...
Linascts's user avatar
  • 159
0 votes
1 answer
705 views

How to search through a jagged array

This code should search an array of decimals for elements that are in a specified range, and return the number of occurrences of the elements that matches the range criteria. The problem is that I am ...
Linascts's user avatar
  • 159
1 vote
1 answer
179 views

VBA: How to access a 2D array inside of an array?

I have an array of 2D arrays. I'm looking to assign a variable to one of the 2D arrays: https://i.stack.imgur.com/SA3Lf.png a = arry(0)(0) gives a "subscript out of range" error. Is there no ...
Kaan's user avatar
  • 21
0 votes
0 answers
97 views

How to use the generic method with the type to convert a List of lists of objects to several DataTables? [duplicate]

I have a genetic method that converst the list to datatable. public static DataTable CreateTable<T>(IList<T> items){ .... ... } So I have a list that has different type of items ...
barteloma's user avatar
  • 6,529
0 votes
2 answers
1k views

How to find the column count of list of lists in C#?

public static void matrix(List<List<int>> matrix) { //matrix.Count is for amount of Row here } Example Here the jagged array is {{ 1, 2, 3}, { 4, 5, 6}, { 7, 8, 9}, {10, 11, ...
Aaqil Ahmed's user avatar

1
2 3 4 5
12