std

The Visula standard library

Outputs

ArrayAn array (vector) of objects
ListA container storing items in a doubly-linked list
TreeA red-black tree. This is used as the base of several other containers.
MapAn associative array: maps objects from one doman to another
SetA set container that does not permit duplicates
MultisetProvides a multiset container
ExitExits the program
SortSorts an entire array
Sort rangeSorts a range of values in an array
GetenvGets an environment variable
Start argsRe-reads all command-line args
Get argGets one command-line argument
RNGA linear-congruential random number generator.
AssertChecks the condition, and if it is false, reports the error
TraceOutputs data for debugging purposes
ErrorAn error-reporting mechanism. Override this.
MultimethodProvides multimethod support

std.Array

An array (vector) of objects

Inputs

initial sizeThe initial size of the array

Outputs

FirstReturns an index to the first item in the array, 0
Get firstGets the first item in the array
Push firstInserts an item at the start of the array
Pop firstRemoves an item from the start of the array
LastReturns an index to the last item in the array
Get lastReturns the last item in the array
PopRemoves the last item in the array
PushInserts an item at the end of the array.
Push lastPushes (appends) an item on the end of the array
Pop lastRemoves and returns the last item in the array, or NULL
EndReturns the end (size) of the array.
NextIncrements the index
PrevDecrements the index
GetGets an item from the array
ResizeResizes the array. Can grow or shrink it.
SizeReturns the number of items in the array.
SetSets an item in the array. Grows the array if necessary
For eachVisits each item in the array
Get keyGets the key for a particular index
Get indexGets the index for a particular key
Get valueGets the value of a particular index (same as Get)
ContainsReturns true if the array contains the key (index)
ValidateValidates the array
InsertInserts an item at a position in the array
RemoveRemoves at item at an index in the array
Remove allMakes the array empty
Remove indexSame as Remove
Insert beforeSame as Insert
Insert afterInserts an item after a particular index
Remove rangeErases a range of elements from the array [NOT IMPLEMENTED]
Is emptyReturns true if the array is empty.

std.Array.First

Returns an index to the first item in the array, 0

Outputs

returnThe index of the first item

std.Array.Get first

Gets the first item in the array

Outputs

returnThe first item

std.Array.Push first

Inserts an item at the start of the array

Inputs

value

Outputs

returnAn index to the first item

std.Array.Pop first

Removes an item from the start of the array

Outputs

returnThe removed item

std.Array.Last

Returns an index to the last item in the array

Outputs

returnAn index

std.Array.Get last

Returns the last item in the array

Outputs

returnThe item

std.Array.Pop

Removes the last item in the array

Outputs

returnThe item that was removed

std.Array.Push

Inserts an item at the end of the array.

Inputs

valueThe value to append

Outputs

returnThe index of the pushed item

std.Array.Push last

Pushes (appends) an item on the end of the array

Inputs

valueThe value to append

std.Array.Pop last

Removes and returns the last item in the array, or NULL

Outputs

returnThe previous last item in the array

std.Array.End

Returns the end (size) of the array.

Outputs

returnA special index

std.Array.Next

Increments the index

Inputs

n

Outputs

returnAn index, or End()

std.Array.Prev

Decrements the index

Inputs

n

Outputs

returnAn index, or End()

std.Array.Get

Gets an item from the array

Inputs

keyThe index (key) to retrieve

Outputs

returnThe item matching the key (index)

std.Array.Resize

Resizes the array. Can grow or shrink it.

Inputs

nThe new size

std.Array.Size

Returns the number of items in the array.

Outputs

returnThe number of items in the array

std.Array.Set

Sets an item in the array. Grows the array if necessary

Inputs

keyThe index to set
valueThe new value.

std.Array.For each

Visits each item in the array

Inputs

visitorThe functor that is called with each array item

std.Array.Get key

Gets the key for a particular index

Inputs

n

Outputs

returnThe key (same as the index)

std.Array.Get index

Gets the index for a particular key

Inputs

nThe key

Outputs

returnThe index (same as the key)

std.Array.Get value

Gets the value of a particular index (same as Get)

Inputs

nThe index

Outputs

returnThe value at the index

std.Array.Contains

Returns true if the array contains the key (index)

Inputs

nThe key

Outputs

returnTrue if the index is valid

std.Array.Validate

Validates the array

Outputs

returnTrue

std.Array.Insert

Inserts an item at a position in the array

Inputs

posThe position (index) to insert at
valueThe value to insert

Outputs

returnThe index of the inserted item

std.Array.Remove

Removes at item at an index in the array

Inputs

posThe index to remove

Outputs

returnThe index of the removed item

std.Array.Remove all

Makes the array empty

std.Array.Remove index

Same as Remove

Inputs

iThe index to remove

Outputs

returnThe index of the removed item

std.Array.Insert before

Same as Insert

Inputs

posThe position to insert at
valueThe value to insert

Outputs

returnThe index of the inserted item

std.Array.Insert after

Inserts an item after a particular index

Inputs

posThe position to insert after
valueThe value to insert

Outputs

returnThe index of the inserted item

std.Array.Remove range

Erases a range of elements from the array [NOT IMPLEMENTED]

Inputs

fromThe first element to erase
toThe last element (exclusive) to erase

std.Array.Is empty

Returns true if the array is empty.

Outputs

returnWhether the array is empty

std.List

A container storing items in a doubly-linked list

Outputs

For eachVisits each item in the list
FirstGets the first index
LastGets the last item in the list
EndThe end of the list
Push firstInserts an item to the front of the list
Pop firstRemoves and returns the item at the front of the list
Push lastInserts an item at the back of the list
Pop lastRemoves and returns the item at the back of the list
PushSame as Push last
PopSame as Pop last
Remove indexRemoves the item with the given index
NextFinds the next index
PrevFind the previous index value
Get valueRetrieves the data at the particular index
Set valueSets the data at the index
Insert beforeInserts an item before the given index
Remove allMakes the entire structure empty
ValidateChecks the data structure is okay and has not been damaged by bugs
Insert afterInsert an item after a given index
Get firstGets the item at the start of the list
Get lastGets the last item in the list
SizeGets the number of items in the list
Is emptyTests whether the structure is empty

std.List.For each

Visits each item in the list

Inputs

visitorThe functor that is called at each visit.

std.List.First

Gets the first index

Outputs

returnThe index of the first item in the list

std.List.Last

Gets the last item in the list

Outputs

returnThe index of the last item in the list

std.List.End

The end of the list

Outputs

returnA special index meaning "end of the list"

std.List.Push first

Inserts an item to the front of the list

Inputs

valueThe value to insert

Outputs

returnThe index of the new node

std.List.Pop first

Removes and returns the item at the front of the list

Outputs

return

std.List.Push last

Inserts an item at the back of the list

Inputs

valueThe value to insert

Outputs

returnThe index of the new node

std.List.Pop last

Removes and returns the item at the back of the list

Outputs

return

std.List.Push

Same as Push last

Inputs

v

Outputs

return

std.List.Pop

Same as Pop last

Outputs

return

std.List.Remove index

Removes the item with the given index

Inputs

i

std.List.Next

Finds the next index

Inputs

n

Outputs

return

std.List.Prev

Find the previous index value

Inputs

n

Outputs

return

std.List.Get value

Retrieves the data at the particular index

Inputs

i

Outputs

returnThe value retrieved

std.List.Set value

Sets the data at the index

Inputs

i
v

std.List.Insert before

Inserts an item before the given index

Inputs

beforeThe index of the item to insert before
valueThe new value to insert

Outputs

returnThe index of the new item

std.List.Remove all

Makes the entire structure empty

std.List.Validate

Checks the data structure is okay and has not been damaged by bugs

Outputs

return

std.List.Insert after

Insert an item after a given index

Inputs

after
value

Outputs

returnThe index of the new item

std.List.Get first

Gets the item at the start of the list

Outputs

returnThe first item in the list

std.List.Get last

Gets the last item in the list

Outputs

returnThe last item in the list

std.List.Size

Gets the number of items in the list

Outputs

returnThe number of items

std.List.Is empty

Tests whether the structure is empty

Outputs

returnTrue if the structure is empty

std.Tree

A red-black tree. This is used as the base of several other containers.

Inputs

lessA comparison function, or null for the default <

Outputs

Insert node
For eachVisits each node in the tree
ValidateValidates the data structure for integrity
FirstGets the first (minimum) index
LastGets the last (maximum) index
EndGets the nil (not found) index
NextFinds the next index for a particular index
PrevFinds the previous index
FindLocate an index in the tree
Remove indexDeletes a node
SizeComputes the number of items in the tree
Is emptyChecks whether the data structure is empty
Get rootRetrieves the root of the tree
Remove allThis deletes every node in the tree.
ContainsTests whether the tree contains the key
NodeAn index in the tree

std.Tree.Insert node

Inputs

n

std.Tree.For each

Visits each node in the tree

Inputs

visitor

std.Tree.Validate

Validates the data structure for integrity

Outputs

return

std.Tree.First

Gets the first (minimum) index

Outputs

returnThe index to the first (minimum) item, or End() if empty

std.Tree.Last

Gets the last (maximum) index

Outputs

returnThe index of the last (maximum) item, or End() if empty

std.Tree.End

Gets the nil (not found) index

Outputs

returnAn index meaning "not found"

std.Tree.Next

Finds the next index for a particular index

Inputs

nThe index

Outputs

returnThe next index, or End()

std.Tree.Prev

Finds the previous index

Inputs

nThe index
Tree predecessor

Outputs

returnThe index to the previous item, or End() if not found

std.Tree.Find

Locate an index in the tree

Inputs

k

Outputs

returnThe index matching the given key, or End() if not found

std.Tree.Remove index

Deletes a node

Inputs

node

std.Tree.Size

Computes the number of items in the tree

Outputs

returnThe number of items in the tree

std.Tree.Is empty

Checks whether the data structure is empty

Outputs

returnTrue if the structure is empty

std.Tree.Get root

Retrieves the root of the tree

Outputs

returnThe root of the tree

std.Tree.Remove all

This deletes every node in the tree.

std.Tree.Contains

Tests whether the tree contains the key

Inputs

k

Outputs

returnTrue if the tree contains the key

std.Tree.Node

An index in the tree

Outputs

keyThe stored key
valueThe stored value
leftThe node to the left
rightThe node to the right
colourThe colour of the node
parentThe parent of the node

std.Map

An associative array: maps objects from one doman to another

Inputs

lessA comparison function, or null for the default <

Outputs

extendsTree
GetGets the value for a particular key
SetSets or inserts a new member of the map.
RemoveRemoves an item matching the given key.
Get firstGets the first item in the map
Get lastGets the last item in the map
For eachVisits each item in the map
Get keyGets the key of a particular index
Get valueGets the value of a particular index
InsertInserts an item in the map. This will insert duplicates
Get rootFrom Tree
EndFrom Tree

std.Map.Get

Gets the value for a particular key

Inputs

k

Outputs

returnThe item found, or null if the key does not exist

std.Map.Set

Sets or inserts a new member of the map.

Inputs

k
v

Outputs

returnThe index of the inserted item

std.Map.Remove

Removes an item matching the given key.

Inputs

k

Outputs

returnThe index of the removed item

std.Map.Get first

Gets the first item in the map

Outputs

returnThe first item in the map, or null if empty

std.Map.Get last

Gets the last item in the map

Inputs

n

Outputs

returnThe value item in the map, or null if empty

std.Map.For each

Visits each item in the map

Inputs

visitor

std.Map.Get key

Gets the key of a particular index

Inputs

i

Outputs

returnThe key of the index

std.Map.Get value

Gets the value of a particular index

Inputs

i

Outputs

returnThe value at the index

std.Map.Insert

Inserts an item in the map. This will insert duplicates

Inputs

key
value

Outputs

returnAn index to the new item

std.Set

A set container that does not permit duplicates

Inputs

less

Outputs

extendsAn extension of Tree
InsertInserts an item into the set. Ignores duplicates.
For each
FirstInherited
EndInherited
NextInherited

std.Set.Insert

Inserts an item into the set. Ignores duplicates.

Inputs

kThe value to insert

Outputs

returnAn index to the item

std.Set.For each

Inputs

visitor

Outputs

i

std.Set.For each.i

Outputs

key

std.Multiset

Provides a multiset container

Inputs

lessThe less functor

Outputs

extendsAn extension of std.Set
InsertInserts an item, allows duplicates
NodeFrom Set
Insert nodeFrom Set

std.Multiset.Insert

Inserts an item, allows duplicates

Inputs

keyThe key to insert

Outputs

returnAn index to the newly inserted node.

std.Exit

Exits the program

Inputs

codeThe exit code, default=0

std.Sort

Sorts an entire array

Inputs

vecThe array to sort
lessThe functor used to compare two values

std.Sort range

Sorts a range of values in an array

Inputs

vec
less
p
r

std.Getenv

Gets an environment variable

Inputs

envThe variable to look up

Outputs

returnThe value of the variable as a string

std.Start args

Re-reads all command-line args

std.Get arg

Gets one command-line argument

Outputs

returnA string containing the argument

std.RNG

A linear-congruential random number generator.

Outputs

GetGets a random integer in the range [0-max()]
SetSets the random seed
MaxReturns the maximum value of Get
GetFloatGets a random number in the range [0-1]

std.RNG.Get

Gets a random integer in the range [0-max()]

Outputs

returnA random integer

std.RNG.Set

Sets the random seed

Inputs

sThe new seed

std.RNG.Max

Returns the maximum value of Get

Outputs

returnThe maximum int

std.RNG.GetFloat

Gets a random number in the range [0-1]

Outputs

returnA number in the range 0-1

std.Assert

Checks the condition, and if it is false, reports the error

Inputs

conditionThe condition to test
textThe text that is reported (optional)

std.Trace

Outputs data for debugging purposes

Inputs

strThe string to output

std.Multimethod

Provides multimethod support

Outputs

extendsAn extension of std.Array
Call1Calls the multimethod with one argument
Call0Calls the multimethod with no arguments

std.Multimethod.Call1

Calls the multimethod with one argument

Inputs

xThe argument that is passed to all methods

Outputs

returnThe return of the last method to be called

std.Multimethod.Call0

Calls the multimethod with no arguments

Outputs

returnThe return of the last method to be called