car - Cell array module
Module Description
The car module implements a dynamic cell array.
Module Words
Cell Array Structure
car%
( - n )
Get the required space for the car data structure
Array creation, initialisation and destruction
car-init
( n:length w:car - )
Initialise the cell array with an initial length
car-create
( C: n:length "name" - R: - w:car )
Create a cell array with an initial length in the dictionary
car-new
( n:length - w:car )
Create a cell array with an initial length on the heap
car-free
( w:car - )
Free the array from the heap
Member words
car-length@
( w:car - u )
Get the number of elements in the array
car-index?
( n w:car - f )
Check if an index is valid in the array
car-size!
( n w:car - )
Insure the size of the array
car-extra@
( w:car - u )
Get the extra space allocated during resizing of the array
car-extra!
( u w:car - )
Set the extra space allocated during resizing of the array
car+extra@
( - u )
Get the initial extra space allocated during resizing of the array
car+extra!
( u - )
Set the initial extra space allocated during resizing of the array
car-compare@
( w:car - xt )
Get the compare execution token for sorting the array
car-compare!
( xt w:car - )
Set the compare execution token for sorting the array
Array words
car-clear
( w:car - )
Clear the array
car-set
( w n:index w:car - )
Set the cell value at the indexth position
car-get
( n:index w:car - w )
Get the cell value from the indexth position
car-append
( w w:car - )
Append the cell value at the end of the array
car-prepend
( w w:car - )
Prepend the cell value before the start of the array
car-insert
( w n:index w:car - )
Insert the cell value at the indexth position
car-delete
( n:index w:car - w )
Delete the cell value at the indexth position, return the previous cell value
Sorting words
car-sort
( w:car - )
Sort the array using the compare execution token using heap sort
car-find-sorted
( w w:car - n f )
Find the cell value in the already sorted array using binary search
car-has-sorted?
( w w:car - f )
Check if a cell value is present in an already sorted array
car-insert-sorted
( w w:car - )
Insert the cell value sorted in an already sorted array
Fifo/Lifo words
car-tos
( w:car - w )
Get the cell value at the end of the array
car-push
( w w:car - )
Push a cell value at the end of the array
car-pop
( w:car - w )
Pop a cell value from the end of the array
car-enqueue
( w w:car - )
Enqueue a cell value at the start of the array
car-dequeue
( w:car - w )
Dequeue a cell value from the end of the array
Special words
car-count
( w w:car - u )
Count the occurences of a cell value in the array
car-find
( w w:car - n:index )
Find the first occurence of a cell value in the array, -1 if not found
car-has?
( w w:car - f )
Check if a cell value is present in the array
car-execute
( ... xt w:car - ... )
Execute the token for every cell in the array
Inspection
car-dump
( w:car - )
Dump the cell array
generated 09-Jan-2007 by
ofcfrth-0.2.0