Skip to content

LinkedList

Hyomoto edited this page Jun 24, 2021 · 3 revisions
Jump To Go Back Methods Variables

LinkedList( )

Implements: IterableList

A GML-based linked list data structure. Can be used as a garbage-collected replacement for the built-in ds_list.

Methods

Jump To top index next previous push insert replace pop clear size

index( index )

Returns: mixed

Throws: IndexOutOfBounds

Name Type Purpose
index int The position to read from

Reads the value at the given index in the list. If the index is out of range an IndexOutOfBounds will be thrown.


next( )

Returns: mixed or EOL

Name Type Purpose
None

Seeks the next value in the list after the last read position, or EOL if the list has been fully traversed. Can use index() to set the next read position.


previous( )

Returns: value or EOL

Name Type Purpose
None

Seeks the previous value in the list before the last read position, or EOL if the front of the list has been reached. Can use index() to set the next read position.


push( *values... )

Returns: self

Name Type Purpose
*values... mixed One or more values

Adds the given values to the end of the list


insert( index, value )

Returns: self

Throws: IndexOutOfBounds

Name Type Purpose
index int The position to insert at
value mixed The value to be inserted

Inserts the value at the given index in the list. If the index is out of range an IndexOutOfBounds will be thrown.


replace( index, value )

Throws: IndexOutOfBounds

Name Type Purpose
index int The position to write to
value Mixed The value to write

Writes the value to the given index in the list. If the index is out of range an IndexOutOfBounds will be thrown.


pop( *index )

Returns: mixed

Throws: IndexOutOfBounds

Name Type Purpose
*index int If provided, the value will be 'popped' from this position

Removes an entry from the list and returns its value. If an index is provided it will remove and return that item, otherwise it will look for the last entry in the list. If the index is out of range, or the list is empty, an IndexOutOfBounds will be thrown.


clear( )

Name Type Purpose
None

Clears the list


size( )

Returns: int

Name Type Purpose
None

Returns the size of the list


Variables

Jump To top
Name Type Initial Purpose
pool undef new ObjectPool() No description.
__First struct undefined A pointer to the first item in the list
__Last struct undefined A pointer to the last item in the list
__Index struct undefined A pointer to the last item traversed in the list
__Size int 0 The size of the list
Clone this wiki locally