The Visula standard library
Outputs
| Array | An array (vector) of objects |
| List | A container storing items in a doubly-linked list |
| Tree | A red-black tree. This is used as the base of several other containers. |
| Map | An associative array: maps objects from one doman to another |
| Set | A set container that does not permit duplicates |
| Multiset | Provides a multiset container |
| Exit | Exits the program |
| Sort | Sorts an entire array |
| Sort range | Sorts a range of values in an array |
| Getenv | Gets an environment variable |
| Start args | Re-reads all command-line args |
| Get arg | Gets one command-line argument |
| RNG | A linear-congruential random number generator. |
| Assert | Checks the condition, and if it is false, reports the error |
| Trace | Outputs data for debugging purposes |
| Error | An error-reporting mechanism. Override this. |
| Multimethod | Provides multimethod support |
An array (vector) of objects
Inputs
| initial size | The initial size of the array |
Outputs
| First | Returns an index to the first item in the array, 0 |
| Get first | Gets the first item in the array |
| Push first | Inserts an item at the start of the array |
| Pop first | Removes an item from the start of the array |
| Last | Returns an index to the last item in the array |
| Get last | Returns the last item in the array |
| Pop | Removes the last item in the array |
| Push | Inserts an item at the end of the array. |
| Push last | Pushes (appends) an item on the end of the array |
| Pop last | Removes and returns the last item in the array, or NULL |
| End | Returns the end (size) of the array. |
| Next | Increments the index |
| Prev | Decrements the index |
| Get | Gets an item from the array |
| Resize | Resizes the array. Can grow or shrink it. |
| Size | Returns the number of items in the array. |
| Set | Sets an item in the array. Grows the array if necessary |
| For each | Visits each item in the array |
| Get key | Gets the key for a particular index |
| Get index | Gets the index for a particular key |
| Get value | Gets the value of a particular index (same as Get) |
| Contains | Returns true if the array contains the key (index) |
| Validate | Validates the array |
| Insert | Inserts an item at a position in the array |
| Remove | Removes at item at an index in the array |
| Remove all | Makes the array empty |
| Remove index | Same as Remove |
| Insert before | Same as Insert |
| Insert after | Inserts an item after a particular index |
| Remove range | Erases a range of elements from the array [NOT IMPLEMENTED] |
| Is empty | Returns true if the array is empty. |
Returns an index to the first item in the array, 0
Outputs
| return | The index of the first item |
Gets the first item in the array
Outputs
| return | The first item |
Inserts an item at the start of the array
Inputs
| value |
Outputs
| return | An index to the first item |
Removes an item from the start of the array
Outputs
| return | The removed item |
Returns an index to the last item in the array
Outputs
| return | An index |
Returns the last item in the array
Outputs
| return | The item |
Removes the last item in the array
Outputs
| return | The item that was removed |
Inserts an item at the end of the array.
Inputs
| value | The value to append |
Outputs
| return | The index of the pushed item |
Pushes (appends) an item on the end of the array
Inputs
| value | The value to append |
Removes and returns the last item in the array, or NULL
Outputs
| return | The previous last item in the array |
Returns the end (size) of the array.
Outputs
| return | A special index |
Increments the index
Inputs
| n |
Outputs
| return | An index, or End() |
Decrements the index
Inputs
| n |
Outputs
| return | An index, or End() |
Gets an item from the array
Inputs
| key | The index (key) to retrieve |
Outputs
| return | The item matching the key (index) |
Resizes the array. Can grow or shrink it.
Inputs
| n | The new size |
Returns the number of items in the array.
Outputs
| return | The number of items in the array |
Sets an item in the array. Grows the array if necessary
Inputs
| key | The index to set |
| value | The new value. |
Visits each item in the array
Inputs
| visitor | The functor that is called with each array item |
Gets the key for a particular index
Inputs
| n |
Outputs
| return | The key (same as the index) |
Gets the index for a particular key
Inputs
| n | The key |
Outputs
| return | The index (same as the key) |
Gets the value of a particular index (same as Get)
Inputs
| n | The index |
Outputs
| return | The value at the index |
Returns true if the array contains the key (index)
Inputs
| n | The key |
Outputs
| return | True if the index is valid |
Validates the array
Outputs
| return | True |
Inserts an item at a position in the array
Inputs
| pos | The position (index) to insert at |
| value | The value to insert |
Outputs
| return | The index of the inserted item |
Removes at item at an index in the array
Inputs
| pos | The index to remove |
Outputs
| return | The index of the removed item |
Makes the array empty
Same as Remove
Inputs
| i | The index to remove |
Outputs
| return | The index of the removed item |
Same as Insert
Inputs
| pos | The position to insert at |
| value | The value to insert |
Outputs
| return | The index of the inserted item |
Inserts an item after a particular index
Inputs
| pos | The position to insert after |
| value | The value to insert |
Outputs
| return | The index of the inserted item |
Erases a range of elements from the array [NOT IMPLEMENTED]
Inputs
| from | The first element to erase |
| to | The last element (exclusive) to erase |
Returns true if the array is empty.
Outputs
| return | Whether the array is empty |
A container storing items in a doubly-linked list
Outputs
| For each | Visits each item in the list |
| First | Gets the first index |
| Last | Gets the last item in the list |
| End | The end of the list |
| Push first | Inserts an item to the front of the list |
| Pop first | Removes and returns the item at the front of the list |
| Push last | Inserts an item at the back of the list |
| Pop last | Removes and returns the item at the back of the list |
| Push | Same as Push last |
| Pop | Same as Pop last |
| Remove index | Removes the item with the given index |
| Next | Finds the next index |
| Prev | Find the previous index value |
| Get value | Retrieves the data at the particular index |
| Set value | Sets the data at the index |
| Insert before | Inserts an item before the given index |
| Remove all | Makes the entire structure empty |
| Validate | Checks the data structure is okay and has not been damaged by bugs |
| Insert after | Insert an item after a given index |
| Get first | Gets the item at the start of the list |
| Get last | Gets the last item in the list |
| Size | Gets the number of items in the list |
| Is empty | Tests whether the structure is empty |
Visits each item in the list
Inputs
| visitor | The functor that is called at each visit. |
Gets the first index
Outputs
| return | The index of the first item in the list |
Gets the last item in the list
Outputs
| return | The index of the last item in the list |
The end of the list
Outputs
| return | A special index meaning "end of the list" |
Inserts an item to the front of the list
Inputs
| value | The value to insert |
Outputs
| return | The index of the new node |
Removes and returns the item at the front of the list
Outputs
| return |
Inserts an item at the back of the list
Inputs
| value | The value to insert |
Outputs
| return | The index of the new node |
Removes and returns the item at the back of the list
Outputs
| return |
Same as Push last
Inputs
| v |
Outputs
| return |
Same as Pop last
Outputs
| return |
Removes the item with the given index
Inputs
| i |
Finds the next index
Inputs
| n |
Outputs
| return |
Find the previous index value
Inputs
| n |
Outputs
| return |
Retrieves the data at the particular index
Inputs
| i |
Outputs
| return | The value retrieved |
Sets the data at the index
Inputs
| i |
| v |
Inserts an item before the given index
Inputs
| before | The index of the item to insert before |
| value | The new value to insert |
Outputs
| return | The index of the new item |
Makes the entire structure empty
Checks the data structure is okay and has not been damaged by bugs
Outputs
| return |
Insert an item after a given index
Inputs
| after |
| value |
Outputs
| return | The index of the new item |
Gets the item at the start of the list
Outputs
| return | The first item in the list |
Gets the last item in the list
Outputs
| return | The last item in the list |
Gets the number of items in the list
Outputs
| return | The number of items |
Tests whether the structure is empty
Outputs
| return | True if the structure is empty |
A red-black tree. This is used as the base of several other containers.
Inputs
| less | A comparison function, or null for the default < |
Outputs
| Insert node | |
| For each | Visits each node in the tree |
| Validate | Validates the data structure for integrity |
| First | Gets the first (minimum) index |
| Last | Gets the last (maximum) index |
| End | Gets the nil (not found) index |
| Next | Finds the next index for a particular index |
| Prev | Finds the previous index |
| Find | Locate an index in the tree |
| Remove index | Deletes a node |
| Size | Computes the number of items in the tree |
| Is empty | Checks whether the data structure is empty |
| Get root | Retrieves the root of the tree |
| Remove all | This deletes every node in the tree. |
| Contains | Tests whether the tree contains the key |
| Node | An index in the tree |
Inputs
| n |
Visits each node in the tree
Inputs
| visitor |
Validates the data structure for integrity
Outputs
| return |
Gets the first (minimum) index
Outputs
| return | The index to the first (minimum) item, or End() if empty |
Gets the last (maximum) index
Outputs
| return | The index of the last (maximum) item, or End() if empty |
Gets the nil (not found) index
Outputs
| return | An index meaning "not found" |
Finds the next index for a particular index
Inputs
| n | The index |
Outputs
| return | The next index, or End() |
Finds the previous index
Inputs
| n | The index |
| Tree predecessor |
Outputs
| return | The index to the previous item, or End() if not found |
Locate an index in the tree
Inputs
| k |
Outputs
| return | The index matching the given key, or End() if not found |
Deletes a node
Inputs
| node |
Computes the number of items in the tree
Outputs
| return | The number of items in the tree |
Checks whether the data structure is empty
Outputs
| return | True if the structure is empty |
Retrieves the root of the tree
Outputs
| return | The root of the tree |
This deletes every node in the tree.
Tests whether the tree contains the key
Inputs
| k |
Outputs
| return | True if the tree contains the key |
An index in the tree
Outputs
| key | The stored key |
| value | The stored value |
| left | The node to the left |
| right | The node to the right |
| colour | The colour of the node |
| parent | The parent of the node |
An associative array: maps objects from one doman to another
Inputs
| less | A comparison function, or null for the default < |
Outputs
| extends | Tree |
| Get | Gets the value for a particular key |
| Set | Sets or inserts a new member of the map. |
| Remove | Removes an item matching the given key. |
| Get first | Gets the first item in the map |
| Get last | Gets the last item in the map |
| For each | Visits each item in the map |
| Get key | Gets the key of a particular index |
| Get value | Gets the value of a particular index |
| Insert | Inserts an item in the map. This will insert duplicates |
| Get root | From Tree |
| End | From Tree |
Gets the value for a particular key
Inputs
| k |
Outputs
| return | The item found, or null if the key does not exist |
Sets or inserts a new member of the map.
Inputs
| k |
| v |
Outputs
| return | The index of the inserted item |
Removes an item matching the given key.
Inputs
| k |
Outputs
| return | The index of the removed item |
Gets the first item in the map
Outputs
| return | The first item in the map, or null if empty |
Gets the last item in the map
Inputs
| n |
Outputs
| return | The value item in the map, or null if empty |
Visits each item in the map
Inputs
| visitor |
Gets the key of a particular index
Inputs
| i |
Outputs
| return | The key of the index |
Gets the value of a particular index
Inputs
| i |
Outputs
| return | The value at the index |
Inserts an item in the map. This will insert duplicates
Inputs
| key |
| value |
Outputs
| return | An index to the new item |
A set container that does not permit duplicates
Inputs
| less |
Outputs
| extends | An extension of Tree |
| Insert | Inserts an item into the set. Ignores duplicates. |
| For each | |
| First | Inherited |
| End | Inherited |
| Next | Inherited |
Inserts an item into the set. Ignores duplicates.
Inputs
| k | The value to insert |
Outputs
| return | An index to the item |
Inputs
| visitor |
Outputs
| i |
Outputs
| key |
Provides a multiset container
Inputs
| less | The less functor |
Outputs
| extends | An extension of std.Set |
| Insert | Inserts an item, allows duplicates |
| Node | From Set |
| Insert node | From Set |
Inserts an item, allows duplicates
Inputs
| key | The key to insert |
Outputs
| return | An index to the newly inserted node. |
Exits the program
Inputs
| code | The exit code, default=0 |
Sorts an entire array
Inputs
| vec | The array to sort |
| less | The functor used to compare two values |
Sorts a range of values in an array
Inputs
| vec |
| less |
| p |
| r |
Gets an environment variable
Inputs
| env | The variable to look up |
Outputs
| return | The value of the variable as a string |
Re-reads all command-line args
Gets one command-line argument
Outputs
| return | A string containing the argument |
A linear-congruential random number generator.
Outputs
| Get | Gets a random integer in the range [0-max()] |
| Set | Sets the random seed |
| Max | Returns the maximum value of Get |
| GetFloat | Gets a random number in the range [0-1] |
Gets a random integer in the range [0-max()]
Outputs
| return | A random integer |
Sets the random seed
Inputs
| s | The new seed |
Returns the maximum value of Get
Outputs
| return | The maximum int |
Gets a random number in the range [0-1]
Outputs
| return | A number in the range 0-1 |
Checks the condition, and if it is false, reports the error
Inputs
| condition | The condition to test |
| text | The text that is reported (optional) |
Outputs data for debugging purposes
Inputs
| str | The string to output |
Provides multimethod support
Outputs
| extends | An extension of std.Array |
| Call1 | Calls the multimethod with one argument |
| Call0 | Calls the multimethod with no arguments |
Calls the multimethod with one argument
Inputs
| x | The argument that is passed to all methods |
Outputs
| return | The return of the last method to be called |
Calls the multimethod with no arguments
Outputs
| return | The return of the last method to be called |