DataStructure["type",data]
represents a data structure.
DataStructure
Listing of Data Structures »DataStructure["type",data]
represents a data structure.
Details
- Data structures provide efficient operations for holding and manipulating data.
- CreateDataStructure[…] returns a DataStructure.
- $DataStructures gives a list of the currently supported data structures.
- Certain data structures, like "DynamicArray" or "HashTable", provide mutable operations in the Wolfram Language.
- Information for a DataStructure includes the following properties:
-
"Type" data structure type "Operations" list of operations supported by the DataStructure "Functions" list of functions that can be applied to the DataStructure - Information for a DataStructure may show details that depend on its specific type.
- DataStructure[…][op,arg1,…] evaluates the operation op with arguments argi.
- Data structures are built using the Wolfram Compiler.
Examples
open all close allBasic Examples (2)
Create a "Stack" data structure:
ds = CreateDataStructure["Stack"]Push multiple elements into the stack:
Do[ds["Push", i], {i, Characters["Hello world!"]}]Get all the elements in the stack:
ds["Elements"]Visualize the contents of the stack:
ds["Visualization"]Create a "HashTable" data structure:
ds = CreateDataStructure["HashTable"]ds["Insert", f[1] -> g[2]]ds["KeyExistsQ", f[1]]ds["Lookup", f[1]]Scope (2)
Information (1)
Create a bit vector data structure:
ds = CreateDataStructure["BitVector", 32]Get information about the data structure:
info = Information[ds]Get the type of the data structure:
info["Type"]Get the capacity for this bit vector data structure:
info["Capacity"]List the operations available to this data structure:
info["Operations"]List the functions available to this data structure:
info["Functions"]Pattern Matching (1)
Create a linked list data structure:
ds = CreateDataStructure["LinkedList"]A function that accepts any data structure:
fun[x_DataStructure] := x
fun[ds]A function that accepts a linked list:
fun1[x : DataStructure["LinkedList", _]] := x
fun1[ds]The function does not accept a stack:
ds1 = CreateDataStructure["Stack"];
fun1[ds1]Properties & Relations (3)
DataStructureQ tests whether an expression is a valid DataStructure:
DataStructureQ[CreateDataStructure["HashSet"]]Use the second argument of DataStructureQ to test whether a data structure is of a specific type:
DataStructureQ[CreateDataStructure["HashSet"], "HashSet"]DataStructureQ[CreateDataStructure["HashSet"], "OrderedHashSet"]Normal can convert a DataStructure to a normal expression:
ds = CreateDataStructure["FixedArray", Range[10]];
Normal[ds]InputForm returns the serialized representation of the DataStructure:
InputForm[CreateDataStructure["OrderedHashTable", <|"x" -> 1, "y" -> 2|>]]See Also
CreateDataStructure DataStructureQ $DataStructures CompiledCodeFunction FunctionCompile Typed
Function Repository: IndexedQueue MergeFindSet
Related Guides
History
Text
Wolfram Research (2020), DataStructure, Wolfram Language function, https://reference.wolfram.com/language/ref/DataStructure.html.
CMS
Wolfram Language. 2020. "DataStructure." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DataStructure.html.
APA
Wolfram Language. (2020). DataStructure. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DataStructure.html
BibTeX
@misc{reference.wolfram_2026_datastructure, author="Wolfram Research", title="{DataStructure}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/DataStructure.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_datastructure, organization={Wolfram Research}, title={DataStructure}, year={2020}, url={https://reference.wolfram.com/language/ref/DataStructure.html}, note=[Accessed: 13-June-2026]}