Static Arrays(Packed Arrays and Unpacked Arrays)
Dynamic Arrays
Associative Arrays
Queues
Static Arrays
1. 一维合并数组
2. 多维合并数组
例一:二维合并数组(32bit或4byte)
例二:三维合并数组(3个32bit)
Unpacked Arrays
1. 一维非合并数组
2. 多维非合并数组
初始化遍历多维数组时,应当写成foreach(stack[i,j])
3. 多维合并+非合并数组
Dynamic Arrays
基本语法
符号:[] new()分配大小并作初始化
动态数组方法(函数)
Function | Description |
---|---|
function int size (); | Returns the current size of the array, 0 if array has not been created |
function void delete (); | Empties the array resulting in a zero-sized array |
为动态数组添加新的数值
id.size+1意味着将array的位数扩展一位
Associative Arrays
基本语法
关联数组方法(函数)
Function | Description |
---|---|
function int num (); | Returns the number of entries in the associative array |
function int size (); | Also returns the number of entries, if empty 0 is returned |
function void delete ( [input index] ); | index when specified deletes the entry at that index, else the whole array is deleted |
function int exists (input index); | Checks whether an element exists at specified index; returns 1 if it does, else 0 |
function int first (ref index); | Assigns to the given index variable the value of the first index; returns 0 for empty array |
function int last (ref index); | Assigns to given index variable the value of the last index; returns 0 for empty array |
function int next (ref index); | Finds the smallest index whose value is greater than the given index |
function int prev (ref index); | Finds the largest index whose value is smaller than the given index |