-
Notifications
You must be signed in to change notification settings - Fork 1
__IterableList__
Jump To | Go Back |
Methods | Abstract | Variables |
---|
Implements: Struct
This is an interface for building python-style lists. To make a new data structure, inherit this constructor and implement the first eight methods. IterableLists are compatible with one another, despite any underlying differences in structure choice. They can be used as stacks, queues, unordered or ordered lists, and sets. When used as an ordered list, binary search is used for insertion and traversal, but this behavior can be changed by overwriting __Search.
Returns: mixed
or EOL
Name | Type | Purpose |
---|---|---|
None |
Returns the first element in the data structure.
Returns: mixed
or ValueNotFound
Name | Type | Purpose |
---|---|---|
None |
Returns the last element in the data structure.
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
first | int |
The first position |
second | int |
The second position |
Swaps the position of the first and second elements.
Returns: mixed
or ValueNotFound
Name | Type | Purpose |
---|---|---|
value | mixed |
The value to be removed |
*func | method |
optional: If provided, will be used for sake of comparison |
Removes the first item in the list that matches value. If no such value exists, a ValueNotFound will be returned.
Returns: int
Name | Type | Purpose |
---|---|---|
value | mixed |
The value to count |
Counts the number of occurences of value in the list.
Returns: IterableList
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
key | mixed |
The value you want to filter by |
*func | method |
optional: If provided, will be used for sake of comparison |
Returns a new IterableList containing all entires that match the key. If func is defined, this value will be passed along with the index key. Returning true will add that value to the final list.
Returns: IterableList
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
sort_or_func | mixed |
The sort type logic to use |
If sort_or_func is true, or no argument is provided, the list will be sorted in ascending order. If false, it will use a descending order. Otherwise, if a function is provided, that will determine the ordering in the list. If an invalid argument is provided, InvalidArgumentType will be thrown.
Returns: IterableList
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
*func | method |
optional: A function to determine comparison |
Returns a new IterableList containing all of the unique entires in this list. If func is provided, the comparison will be done against the results of the function. If this value is not a method, InvalidArgumentType will be thrown.
Returns: IterableList
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
list | mixed |
The list to combine with |
*func | method |
optional: A function to determine comparison |
Returns a new IterableList combining all unique entries in this list and list. If func is provided, the comparison will be done against the results of the function. If this value is not a method, InvalidArgumentType will be thrown.
Returns: IterableList
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
list | mixed |
The list to intersect with |
*func | method |
optional: A function to determine comparison |
Returns a new IterableList containing all of the entries shared with list. If func is provided, the comparison will be done against the results of the function. If this value is not a method, InvalidArgumentType will be thrown.
Returns: IterableList
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
list | mixed |
The list to difference with |
*func | method |
optional: A function to determine comparison |
Returns a new IterableList containing all of the entires not in the list. If func is provided, the comparison will be done against the results of the function. If this value is not a method, InvalidArgumentType will be thrown.
Returns: IterableList
Name | Type | Purpose |
---|---|---|
None |
Returns a new IterableList containing all the elements of this list reversed.
Returns: IterableList
Name | Type | Purpose |
---|---|---|
random | Randomizer | optional: A randomizer to use for shuffling |
Returns a new IterableList with the elements of the list randomized using a Fischer-Yates shuffle. If a randomizer is provided, that will be used instead of the GMS random functions.
Returns: mixed
or ValueNotFound
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
value... | mixed |
The value to find |
*func | method |
optional: The function to use to check for matches |
Checks if the value exists in this list. If it does not, a ValueNotFound error will be returned. This can be check with the error_type() function. If func is provided, the return of that function will be used for comparison. If func is not a method, InvalidArgumentType will be thrown.
Name | Type | Purpose |
---|---|---|
value... | mixed |
The value(s) to check for |
*func | method |
optional: A function to determine comparison |
Returns true if the list contains all of the given values
Returns: IterableList
Name | Type | Purpose |
---|---|---|
None |
Returns a copy of this IterableList
Returns: bool
Name | Type | Purpose |
---|---|---|
None |
Returns if the list is empty
Name | Type | Purpose |
---|---|---|
false | bool |
Whether or not to allow duplicates |
If true, or a argument is not provided, duplicates will not be added to the list.
Name | Type | Purpose |
---|---|---|
sort_or_func | mixed |
The sorting method to use |
If sort_or_func is true, or no argument is provided, the list will be ordered in ascending fashion. If false, it will use a descending order. Otherwise, if a function is provided, that will determine the ordering in the list.
Returns: self
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
input | InputStream | An InputStream to read from. |
close | bool |
If false, the stream will not be closed after reading |
Populates this structure with values from the provided input stream. By default, the stream will be closed afterwards. If close is false, however, this behavior will be overridden. If input is not an InputStream, InvalidArgumentType will be thrown.
Returns: output
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
output | Stream | An stream to write to |
close | bool |
If false, the stream will not be closed after writing |
*func | method |
If provided, is used to determine what is sent to the stream |
Writes this data structure to the provided output stream. By default, the stream will be closed after writing. If close is false, however, this behavior will be overridden. If output is not a Stream or func is not a method, InvalidArgumentType will be thrown.
Name | Type | Purpose |
---|---|---|
array | array |
An array of values |
Populates this structure with values from the provided array.
Returns: array
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
*func | method |
If provided, is used to populate the array. |
Returns this list as an array. If func is defined, the value is passed into the function and the return is written instead. If func is provided, but not a method, InvalidArgumentType is thrown.
Returns: self
Throws: InvalidArgumentType, UnexpectedTypeMismatch
Name | Type | Purpose |
---|---|---|
JSON_string | string |
The string to convert into a list |
Takes the provided string and uses it to populate the list. If a string is not provided, InvalidArgumentType is thrown. If the string does not convert into an array UnexpectedTypeMismatch will be thrown.
Name | Type | Purpose |
---|---|---|
None |
Returns this list as a JSON string
Returns: string
Name | Type | Purpose |
---|---|---|
None |
Converts this structure into a string and returns it.
Jump To | top |
---|
Retrieves the value at the given index and sets the traversal pointer
Returns the next value in the list, or EOL if the end has been reached
Returns the previous value in the list, or EOL if the end has been reached
Adds the given values to the list
Inserts the value at the given index
Replaces the element at the given index with the new value
Pops the last value off the list, or the index if provided
Clears the list
Returns the size of the list
Jump To | top |
---|
Name | Type | Initial | Purpose |
---|---|---|---|
EOL | struct |
constant | The pointer that is returned when the end of list is reached |
__Dupes | bool |
true | Whether or not this IterableList will accept duplicates |
__OrderedBy | method |
undefined | The function used to perform ordered insertions |
Devon Mullane 2020