\ B-tree list vandys
\ Implementation of a B-tree whose leaves are Sets. Cogbot
\ uses this in a number of places, so we implement this as
\ its own data structure here.
only extensions definitions
Btree -> subclass: BtSet
BtSet -> :method ! { val key self -- }
key self super-> @ 0= if
Set -> new dup key self super-> ! then
( set ) val swap -> add method;
: .btl ( 0 set key -- ) . ." ->" -> . drop ; scrLocal
BtSet -> :method .elems ( self -- ) 0 ['] .btl rot -> do method;
: (empty!) ( 0 set -- ) nip -> free ; scrLocal
BtSet -> :method empty! ( self -- ) dup 0 ['] (empty!) rot -> do
( self ) super-> empty! method;
\ B-tree list vandys
vandys
A BtSet is just a Btree whose leaves are formatted specially
:method ! The value provided is to join the Set under this key
: .btl Internal function to display a single entry in the BtSet
:method .elems Display the BtSet's contents
: (empty!) Iterator, to empty out each Set underneath us
:method empty! Free the Set's held as our leaves, then null our Btree
vandys