Michael Heilmann's Arcadia Collections
This is the documentation for Michael Heilmann's Arcadia Collections. Arcadia Collections provides collections like lists, deques, and maps. Arcadia Collections is available at michaelheilmann.com/Arcadia/Ring2.
Files
You can find the sources of Arcadia Collections in my GitHub repository https://github.com/michaelheilmann/arcadia. The subdirectory of Arcadia Collections in the repository is here https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Collections.
- The (sources of the) library resides in the directory https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Collections/Library
- The (sources of) tests reside in the directory https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Collections/Tests
- The (sources of this very documentation you are reading) documentation reside in the directory https://github.com/michaelheilmann/arcadia/tree/main/Runtime/Collections/Documentation
Arcadia Ring 2 supports various platforms (including but not restricted to Windows, Linux, and many more), however, we currently only officially support Windows. For instructions on how to build, test, and use Arcadia Collections, refer to README.md in the root folder of the repository.
Further References
Arcadia Ring 2 relies on Arcadia Ring 1 and Arcadia ARMS.
Documentation
Objects
ArrayList
Arcadia_ArrayList extends Arcadia_List.
An Arcadia_List implemented using arrays.
Arcadia_ArrayList_create
Arcadia_ArrayList*
Arcadia_ArrayList_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Errors
Return value
A pointer to the Arcadia_ArrayList object.
Collection
Arcadia_Collection extends Arcadia_Object.
Arcadia_Collection represents a collection of Arcadia_Value objects.
Arcadia_Collection_clear
void
Arcadia_Collection_clear
(
Arcadia_Thread* thread,
Arcadia_Collection* self
)
Parameters
Arcadia_Thread object.Arcadia_Collection_getSize
Arcadia_SizeValue
Arcadia_Collection_getSize
(
Arcadia_Thread* thread,
Arcadia_Collection* self
)
Parameters
Arcadia_Thread object.Return value
The size of this collection.
Errors
self is a null pointer.Arcadia_Collection_isEmpty
Arcadia_BooleanValue
Arcadia_Collection_isEmpty
(
Arcadia_Thread* thread,
Arcadia_Collection* self
)
Parameters
Arcadia_Thread object.Return value
Arcadia_BooleanValue_True if this collection is empty. Arcadia_BooleanValue_False otherwise.
Errors
self is a null pointer.HashMap
Arcadia_HashMap extends Arcadia_Map.
An Arcadia_Map implemented using hash tables.
Arcadia_HashMap_create
Arcadia_HashMap*
Arcadia_HashMap_create
(
Arcadia_Thread* thread,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.Errors
Return value
A pointer to the Arcadia_HashMap object.
Remarks
If value is a hash map value, then the hash map entries of that hash map are added to the hash map which is created.
HashSet
Arcadia_HashSet extends Arcadia_Set.
An Arcadia_Set implemented using hash tables.
Arcadia_HashSet_create
Arcadia_HashSet*
Arcadia_HashSet_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Errors
Return value
A pointer to the Arcadia_HashSet value.
Arcadia_List
Arcadia_List extends Arcadia_Collection.
Arcadia_List represents a list of Arcadia_Value objects.
Arcadia_List_getAt
Arcadia_Value
Arcadia_List_getAt
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_SizeValue index
)
Parameters
Arcadia_Thread object.[0,n) where n is the size of this list.Errors
index is out of bounds.Return value
The value.
Arcadia_List_insertAt
void
Arcadia_List_insertAt
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_SizeValue index,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.[0,n] where n is the size of thie list.Errors
index is out of bounds.value is a Void value.Arcadia_List_insertBack
void
Arcadia_List_insertBack
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.Errors
value is a Void value.Arcadia_List_insertFront
void
Arcadia_List_insertFront
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.Errors
value is a Void value.Arcadia_List_removeAt
void
Arcadia_List_removeAt
(
Arcadia_Thread* thread,
Arcadia_List* self,
Arcadia_SizeValue start,
Arcadia_SizeValue length
)
length values starting with element at index start.
Parameters
Arcadia_Thread object.Errors
self is a null pointer.index + length > n where n is the length of the list.Map
Arcadia_Map extends Arcadia_Collection.
Arcadia_Map represents a map from Arcadia_Value objects, the keys, to Arcadia_Value objects, the values.
Arcadia_Map_get
Arcadia_Value
Arcadia_Map_get
(
Arcadia_Thread* thread,
Arcadia_Map* self,
Arcadia_Value key
)
Get the value of an entry for a given key in this map.
More formally: Let \(x\) be the specified key.
- If there exist an entry \(x' \mapsto y'\) in the map such that \(x\) is equivalent to \(x'\), then y' is returned.
- Otherwise (if there exists no such entry in the map), then a Void value is returned.
Parameters
Arcadia_Thread object.Arcadia_Map object.Return value
The value for the given key if it was found. A Void value otherwise.
Errors
key is a Void value.Arcadia_Map_remove
Arcadia_Value
Arcadia_Map_set
(
Arcadia_Thread* thread,
Arcadia_Stack* self,
Arcadia_Value key
)
Remove an entry for a given key from this map.
More formally: Let \(x\) be the specified key and \(y\) be the specified value.
- If \(y\) is an Void value then there are two cases:
- If there exist an entry \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is removed and y' is returned.
- Otherwise (if there exists no such entry in the map), then a Void value is returned.
- Otherwise (\(y\) is not an Void value) then there are two cases:
- If there exist one \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is replaced by the entry \((x' \mapsto y)\) and y' is returned.
- Otherwise the entry \((x \mapsto y)\) is added and an Void value is returned.
Parameters
Arcadia_Thread object.Return value
The value of the removed entry \((x \mapsto y)\) such an entry was found. A Void value otherwise.
Errors
key is a Void value.Arcadia_Map_set
void
Arcadia_Map_set
(
Arcadia_Thread* thread,
Arcadia_Stack* self,
Arcadia_Value key,
Arcadia_Value value
Arcadia_Value* oldKey,
Arcadia_Value* oldValue,
)
Set the value for the given key in this map.
More formally: Let \(x\) be the specified key and \(y\) be the specified value.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- If \(y\) is an Void value then there are two cases:
-
If there exist an entry \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is removed.
\(x'\) is returned in
*oldKeyif oldKey is not null. \(y'\) is returned in*oldValueif oldValue is not null. -
Otherwise (if there exists no such entry in the map):
Void value is returned in
*oldKeyif oldKey is not null. Void value is returned in*oldValueif oldValue is not null.
-
If there exist an entry \((x' \mapsto y')\) in the map such that \(x\) is equivalent to \(x'\), then this entry is removed.
\(x'\) is returned in
- Otherwise (\(y\) is not an Void value) then there are two cases:
-
If there exist one \(x' \mapsto y'\) in the map such that \(x\) is equivalent to \(x'\), then this entry is replaced by the entry \(x \mapsto y\).
\(x'\) is returned in
*oldKeyif oldKey is not null. \(y'\) is returned in*oldValueif oldValue is not null. -
Otherwise the entry \(x \mapsto y\) is added.
Void value is returned in
*oldKeyif oldKey is not null. Void value is returned in*oldValueif oldValue is not null.
Parameters
Arcadia_Thread object.Return value
The value of the removed entry \((x' \mapsto y')\) if an entry for the given key if it was found. A Void value otherwise.
Errors
key is a Void value.Set
Arcadia_Set extends Arcadia_Collection.
Arcadia_Set represents a set of Arcadia_Value objects.
Arcadia_Set_contains
Arcadia_BooleanValue
Arcadia_Set_contains
(
Arcadia_Thread* thread,
Arcadia_Set* self,
Arcadia_Value value
)
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (that is, if \(x\) is not an Void value):
- If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), then Arcadia_BooleanValue_True is returned.
- Otherwise Arcadia_BooleanValue_False is returned.
Parameters
Arcadia_Thread object.Arcadia_Set object.Return value
Arcadia_BooleanValue_True if \(x\) contained in this set.
Arcadia_BooleanValue_False otherwise.
Arcadia_Set_get
Arcadia_Value
Arcadia_Set_get
(
Arcadia_Thread* thread,
Arcadia_Set self,
Arcadia_Value value
)
Get the value in this set.
More formally: Let \(x\) be the value to get.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (\(x\) is not an Void value) then there are two cases:
- If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), then \(x'\) is returned.
- Otherwise the Void value is returned.
Parameters
Arcadia_Thread object.Return value
The value \(x'\) or the Void value.
Arcadia_Set_add
void
Arcadia_Set_add
(
Arcadia_Thread* thread,
Arcadia_Set self,
Arcadia_Value value,
Arcadia_Value* oldValue
)
Add value to this set.
More formally: Let \(x\) be the value to be added.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (\(x\) is not an Void value) then there are two cases:
-
If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), \(x'\) is replaced by \(x\) in this set.
\(x'\) is returned in
*oldValueif oldValue is not null. -
Otherwise \(x\) is added to this set.
Void value is returned in
*oldValueifoldValueis not a null pointer.
Parameters
Arcadia_Thread object.Arcadia_Value object or a null pointer.Return value
Arcadia_BooleanValue_True if \(x\) was added to this set. Arcadia_BooleanValue_False otherwise.
Arcadia_Set_remove
void
Arcadia_Set_remove
(
Arcadia_Thread* thread,
Arcadia_Set* self,
Arcadia_Value value,
Arcadia_Value *oldValue
)
Remove a value from this set.
More formally: Let \(x\) be the value to be removed.
- If \(x\) is an Void value, then an Argument Type Invalid error is raised.
- Otherwise (\(x\) is not an Void value) then there are two cases:
-
If there exist one \(x'\) in the map such that \(x\) is equivalent to \(x'\), \(x'\) is removed from this set.
\(x'\) is returned in
*oldValueif oldValue is not null. -
Void value is returned in
*oldValueifoldValueis not a null pointer.
Parameters
Arcadia_Thread object.Arcadia_Value object or a null pointer.Return value
Arcadia_BooleanValue_Trueif value was removed to this set. Arcadia_BooleanValue_False otherwise.
Stack
Arcadia_Stack extends Arcadia_Collection.
Arcadia_Stack represents a stack of Arcadia_Value objects.
Arcadia_Stack_create
Arcadia_Stack*
Arcadia_Stack_create
(
Arcadia_Thread* thread
)
Parameters
Arcadia_Thread object.Errors
Return value
A pointer to the Arcadia_Stack value.
Arcadia_Stack_peek
Arcadia_Value
Arcadia_Stack_peek
(
Arcadia_Thread* thread,
Arcadia_Stack* self
)
Parameters
Arcadia_Thread object.Return value
The value.
Errors
Arcadia_Stack_pop
Arcadia_Value
Arcadia_Stack_pop
(
Arcadia_Thread* thread,
Arcadia_Stack* self
)
Parameters
Arcadia_Thread object.Return value
The value.
Errors
Arcadia_Stack_push
void
Arcadia_Stack_push
(
Arcadia_Thread* thread,
Arcadia_Stack* self,
Arcadia_Value value
)
Parameters
Arcadia_Thread object.Errors
value is a Void value.