"FixedArray" (Data Structure)
"FixedArray"
represents an array of fixed length where the elements are general expressions.
Details
- A fixed-length array is useful for efficient element extraction and updating:
-
CreateDataStructure[ "FixedArray",n] create a new "FixedArray" with n elements CreateDataStructure[ "FixedArray",x,n] create a new "FixedArray" of length n initialized to x CreateDataStructure[ "FixedArray",elems] create a new "FixedArray" containing elems Typed[x,"FixedArray"] give x the type "FixedArray" - For a data structure of type "FixedArray", the following operations can be used:
-
ds["Copy"] return a copy of ds time: O(n) ds["Elements"] return a list of the elements of ds time: O(n) ds["EmptyQ"] True, if ds has no elements time: O(1) ds["Fold",fun,init] apply fun to the elements of ds, starting with init, accumulating a result time: O(n) ds["Length"] number of elements stored in ds time: O(1) ds["Part",i] give the i part of ds time: O(1) ds["SetPart",i,elem] update the i part of ds time: O(1) ds["SwapPart",i,j] swap the i and j parts of ds time: O(1) ds["Visualization"] return a visualization of ds time: O(n) - The following functions are also supported:
-
dsi===dsj True, if dsi equals dsj ds["Part",i]=val set i element of ds to val FullForm[ds] full form of ds Information[ds] information about ds InputForm[ds] input form of ds Normal[ds] convert ds to a normal expression
Examples
open allclose allBasic Examples (3)
A new "FixedArray" can be created with CreateDataStructure:
Return an expression version of ds. The elements are initialized to Null:
It is fast to update elements:
Scope (1)
Information (1)
A new "FixedArray" can be created with CreateDataStructure:
Properties & Relations (1)
"DynamicArray" (1)
Many algorithms that work for "DynamicArray" also work for "FixedArray".
Possible Issues (2)
Interactive Examples (1)
Compute and store individual plots in a data structure and use Manipulate to interactively display them: