Jagged array - Wikipedia
文章推薦指數: 80 %
In computer science, a jagged array, also known as a ragged array, is an array of arrays of which the member arrays can be of different lengths, ...
Jaggedarray
FromWikipedia,thefreeencyclopedia
Jumptonavigation
Jumptosearch
Memorylayoutofajaggedarray.
Incomputerscience,ajaggedarray,alsoknownasaraggedarray[citationneeded],isanarrayofarraysofwhichthememberarrayscanbeofdifferentlengths,[1]producingrowsofjaggededgeswhenvisualizedasoutput.Incontrast,two-dimensionalarraysarealwaysrectangular[2]sojaggedarraysshouldnotbeconfusedwithmultidimensionalarrays,buttheformerisoftenusedtoemulatethelatter.
ArraysofarraysinlanguagessuchasJava,PHP,Python(multidimensionallists),Ruby,C#.Net,VisualBasic.NET,Perl,JavaScript,Objective-C,Swift,andAtlasAutocodeareimplementedasIliffevectors.
Examples[edit]
InC#andJava[3]jaggedarrayscanbecreatedwiththefollowingcode:[4]
int[][]c;
c=newint[2][];//creates2rows
c[0]=newint[5];//5columnsforrow0
c[1]=newint[3];//create3columnsforrow1
InCandC++,ajaggedarraycanbecreated(onthestack)usingthefollowingcode:
intjagged_row0[]={0,1};
intjagged_row1[]={1,2,3};
int*jagged[]={jagged_row0,jagged_row1};
InC/C++,jaggedarrayscanalsobecreated(ontheheap)withanarrayofpointers:
int*jagged[5];
jagged[0]=malloc(sizeof(int)*10);
jagged[1]=malloc(sizeof(int)*3);
InC++/CLI,jaggedarraycanbecreatedwiththecode:[5]
usingnamespaceSystem;
intmain()
{
array
延伸文章資訊
- 1不規則陣列- C# 程式設計手冊 - Microsoft Docs
Assign 77 to the second element ([1]) of the first array ([0]): jaggedArray3[0][1] = 77; // Assig...
- 2Jagged array - Wikipedia
In computer science, a jagged array, also known as a ragged array, is an array of arrays of which...
- 3C# Jagged Array (With Examples) - Programiz
In C#, a jagged array consists of multiple arrays as its element. However, unlike multidimensiona...
- 4Jagged Array in Java - GeeksforGeeks
A jagged array is an array of arrays such that member arrays can be of different sizes, i.e., we ...
- 5C# Jagged Arrays: An Array of Array - TutorialsTeacher
A jagged array is an array of array. Jagged arrays store arrays instead of literal values. A jagg...