CreateDataStructure["type",arg1,arg2,…]
creates a data structure with the specified type.
CreateDataStructure
Listing of Data Structures »CreateDataStructure["type",arg1,arg2,…]
creates a data structure with the specified type.
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.
- Data structures are built with the Wolfram Compiler.
Examples
open all close allBasic Examples (4)
Create an instance of an array that grows dynamically:
ds = CreateDataStructure["DynamicArray"]Append an expression to the array:
ds["Append", f[1]]Update an element of the array:
ds["Part", 1] = f[-1]The stack contents can be viewed as a normal expression:
Normal[ds]Create a "Stack" data structure:
ds = CreateDataStructure["Stack"]Do[ds["Push", i], {i, Characters["Hello world!"]}]"Pop" removes the most recently added element:
ds["Pop"]The stack contents can be viewed as a normal list:
ds["Elements"]Create an "OrderedHashTable" to store and retrieve values by key:
ds = CreateDataStructure["OrderedHashTable"]ds["Insert", "x" -> 10]List all keys in insertion order:
ds["Keys"]ds["Lookup", "x"]Create an "ExprStruct" to store and manipulate expressions without evaluation:
ds = CreateDataStructure["ExprStruct", f[x, y]]Visualize the stored expression:
ds["Visualization"]Return a new "ExprStruct" that wraps the expression with h:
ds1 = ds["ConstructWith", h]Return the expression held in the new data structure:
ds1["Get"]Scope (2)
Create an empty "DynamicArray":
CreateDataStructure["DynamicArray"]Create an empty "HashSet":
CreateDataStructure["HashSet"]Create an empty "OrderedHashTable":
CreateDataStructure["OrderedHashTable"]Create a "DynamicArray" with initial values:
CreateDataStructure["DynamicArray", Range[1000]]Create a "HashSet" with initial elements:
CreateDataStructure["HashSet", {x, y, z}]Create an "OrderedHashTable" with initial key-value pairs:
CreateDataStructure["OrderedHashTable", <|"a" -> 1, "b" -> 2, "c" -> 3|>]Properties & Relations (2)
$DataStructures gives a list of the currently supported data structures:
$DataStructuresDataStructureQ 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"]Related Guides
History
Text
Wolfram Research (2020), CreateDataStructure, Wolfram Language function, https://reference.wolfram.com/language/ref/CreateDataStructure.html.
CMS
Wolfram Language. 2020. "CreateDataStructure." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CreateDataStructure.html.
APA
Wolfram Language. (2020). CreateDataStructure. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CreateDataStructure.html
BibTeX
@misc{reference.wolfram_2026_createdatastructure, author="Wolfram Research", title="{CreateDataStructure}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/CreateDataStructure.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_createdatastructure, organization={Wolfram Research}, title={CreateDataStructure}, year={2020}, url={https://reference.wolfram.com/language/ref/CreateDataStructure.html}, note=[Accessed: 12-June-2026]}