LitDev Extension API
LDFastArray
This object provides another faster way of storing values in an Array.
It can handle 1, 2, 3 and higher dimensional arrays and has methods to read and write arrays to files, including in CSV format.
It is also possible for different rows in an array to have different dimensions or numbers of elements (jagged array), just like Small Basic arrays.
Internally it uses lists that allow the sizes to grow so that the array dimension or size doesn't need to be set at the start.
The indexing is by integer starting from 1.
For 1D arrays it is recommended to use LDList since it has additional sort methods.
Elements in arrays with dimension greater than 3 are indexed by a comma separated list of indices or index variable names.
Add | Collapse | Copy |
CreateFromIndices | CreateFromValues | Dimension |
Get | Get1D | Get2D |
Get3D | Read | ReadCSV |
Remove | Set | Set1D |
Set2D | Set3D | Size |
Size1 | Size2 | Size3 |
ToArray | Write | WriteCSV |
Add()
Create a new array.
This is a general array that can be used as a 1D, 2D, 3D or higher dimension array, depending on the data set.
returns The array name.
Collapse(arrayName)
Remove all empty "" entries in an array.
Note that indices or even dimensions may change if internal entries are removed.
arrayName The array name.
Copy(arrayName)
Copy an array.
arrayName The array name.
returns A copy of the array.
CreateFromIndices(sbArray)
Convert a SmallBasic array (up to 3 dimensions) to a FastArray array.
This method creates an array only containing the Small Basic array indices.
sbArray The Small Basic array.
returns A new FastArray or "".
CreateFromValues(sbArray)
Convert a SmallBasic array to a FastArray array.
All indices in the Small Basic array are replaced with consecutive integer indices.
sbArray The Small Basic array.
returns A new FastArray or "".
Dimension(arrayName)
Get the dimension of an array.
arrayName The array name.
returns The array dimension.
Get(arrayName,indices)
Get a value.
Get1D, Get2D or Get3D methods are marginally faster for lower dimension arrays.
arrayName The array name.
indices A comma (or space) separated list of index values (slower) or index variable names (faster).
e.g. "3,2,6" or "i,j,k"
If this is set to "", then previously set index variables are used.
returns The array value or "" on failure.
Get1D(arrayName,index1)
Get a 1D value.
arrayName The array name.
index1 The first dimension integer index.
returns The array value or "" on failure.
Get2D(arrayName,index1,index2)
Get a 2D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
returns The array value or "" on failure.
Get3D(arrayName,index1,index2,index3)
Get a 3D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
index3 The third dimension integer index.
returns The array value or "" on failure.
Read(fileName,binary)
Create a new array and initialise it from a file.
If the file is text based and doesn't have the same indexing format as Write, then a 1D array with each line is created.
fileName The full path of the file.
binary Binary ("True") or text ("False") formatted file.
returns The array name.
ReadCSV(fileName)
Read a CSV (comma separated values) file into a 2D FastArray array.
The deliminator may be changed from a comma using Utilities.CSVDeliminator
fileName The full path of the CSV file.
returns A 2D FastArray with CSV file imported or "".
Remove(arrayName)
Delete an array.
arrayName The array name.
Set(arrayName,indices,value)
Set a value.
Set1D, Set2D or Set3D methods are marginally faster for lower dimension arrays.
arrayName The array name.
indices A comma (or space) separated list of index values (slower) or index variable names (faster).
e.g. "3,2,6" or "i,j,k"
If this is set to "", then previously set index variables are used.
value The value to set.
Set1D(arrayName,index1,value)
Set a 1D value.
arrayName The array name.
index1 The first dimension integer index.
value The value to set.
Set2D(arrayName,index1,index2,value)
Set a 2D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
value The value to set.
Set3D(arrayName,index1,index2,index3,value)
Set a 3D value.
arrayName The array name.
index1 The first dimension integer index.
index2 The second dimension integer index.
index3 The third dimension integer index.
value The value to set.
Size(arrayName,indices)
Get the current size of a dimension.
Size1, Size2 or Size3 methods are marginally faster for lower dimension arrays.
arrayName The array name.
indices A comma (or space) separated list of indices.
e.g. "" for first dimension or "3" for second dimension of 3rd element in first dimension.
returns The dimension size.
Size1(arrayName)
Get the current size of the first dimension.
arrayName The array name.
returns The dimension size.
Size2(arrayName,index1)
Get the current size of the second dimension.
arrayName The array name.
index1 The first index to get the size of, may be 1 if all rows have the same size.
returns The dimension size.
Size3(arrayName,index1,index2)
Get the current size of the third dimension.
arrayName The array name.
index1 The first index to get the size of, may be 1 if all rows have the same size.
index2 The second index to get the size of, may be 1 if all rows have the same size.
returns The dimension size.
ToArray(arrayName)
Convert a FastArray array to a Small Basic array.
arrayName The array name.
returns A Small Basic array or "".
Write(arrayName,fileName,binary)
Save an array to a file.
If the array is 1D and written as a text, then each entry is just written to a line with no indexing.
arrayName The array name.
fileName The full path of the file.
binary Binary ("True") or text ("False") formatted file.
WriteCSV(arrayName,fileName)
Write a 2D FastArray array to a CSV (comma separated values) file.
The deliminator may be changed from a comma using Utilities.CSVDeliminator
arrayName The 2D array name.
fileName The full path of the CSV file.