Vocabulary
persistent.hashtables.nodes

Inputs
keyan object
hashcodean object
nodean object


Outputs
node'an object


Definition

GENERIC: (pluck-at) ( key hashcode node -- node' )


Methods

M:: bitmap-node (pluck-at)
( key hashcode bitmap-node -- node' )
hashcode bitmap-node shift>> bitpos
:> bit bitmap-node bitmap>> :> bitmap bitmap-node nodes>>
:> nodes bitmap-node shift>> :> shift bit bitmap bitand
0 eq?
[ bitmap-node ] [
bit bitmap index :> idx idx nodes nth-unsafe
:> n key hashcode n (pluck-at) :> n' n n' eq?
[ bitmap-node ] [
n'
[ bitmap n' idx nodes new-nth shift <bitmap-node> ]
[
bitmap bit eq?
[ f ] [
bitmap bit bitnot bitand
idx nodes remove-nth shift <bitmap-node>
] if
] if
] if
] if ;



M:: collision-node (pluck-at)
( key hashcode collision-node -- node' )
hashcode collision-node hashcode>> eq? [
key hashcode collision-node find-index drop :> idx idx [
idx collision-node leaves>> smash
[ collision-node hashcode>> <collision-node> ] when
] [ collision-node ] if
] [ collision-node ] if ;






M:: full-node (pluck-at) ( key hashcode full-node -- node' )
hashcode full-node shift>> mask
:> idx idx full-node nodes>> nth
:> n key hashcode n (pluck-at) :> n' n n' eq?
[ full-node ] [
n' [
n' idx full-node nodes>> new-nth
full-node shift>> <full-node>
] [
hashcode full-node shift>> bitpos
bitnot full-bitmap-mask bitand
idx full-node nodes>> remove-nth
full-node shift>> <bitmap-node>
] if
] if ;