bar - Bit array module
Module Description
The bar module implements a bit array.
Module Words
Bit array structure
bar%
( -- n )
Get the required space for a bar variable
Array creation, initialisation and destruction
bar-init
( +n bar -- )
Initialise the array with length n
bar-(free)
( bar -- )
Free the internal data from the heap
bar-create
( +n "<spaces>name" -- ; -- bar )
Create a bit array in the dictionary with length n
bar-new
( n -- bar )
Create a bit array on the heap with length n
bar-free
( bar -- )
Free the array from the heap
Member words
bar-length@
( bar -- +n )
Get the number of bits in the array
bar-index?
( n bar -- flag )
Check if the index n is valid in the array
Bit set words
bar-set-bit
( n bar -- )
Set the nth bit in the array
bar-set-bits
( u n bar -- )
Set a range of bits in the array, starting from the nth bit, u bits long
bar-set
( bar -- )
Set all bits in the array
Bit reset words
bar-reset-bit
( n bar -- )
Reset the nth bit
bar-reset-bits
( u n bar -- )
Reset a range of bits in the array, starting from the nth bit, u bits long
bar-reset
( bar -- )
Reset all bits in the array
Bit invert words
bar-invert-bit
( n bar -- )
Invert the nth bit
bar-invert-bits
( u n bar -- )
Invert a range of bits in the array, starting from the nth bit, u bits long
bar-invert
( bar -- )
Invert all bits in the array
Bit check words
bar-get-bit
( n bar -- flag )
Check if the nth bit is set
bar-count-bits
( +n1 n2 bar -- u )
Count the number of bits set in a range in the array, starting from the n2th bit, n1 bits long
bar-count
( bar -- u )
Count the number of bits set in the array
bar-execute
( i*x xt bar -- j*x )
Execute xt for every bit in the array
Inspection
bar-dump
( bar -- )
Dump the bit array
generated 10-Apr-2008 by
ofcfrth-0.5.0