Handbook
Glossary
(pluck-at) ( key hashcode node -- node' )
Vocabulary
persistent
.
hashtables
.
nodes
Inputs
key
an
object
hashcode
an
object
node
an
object
Outputs
node'
an
object
Definition
IN:
persistent.hashtables.nodes
GENERIC:
(pluck-at)
( key hashcode node -- node' )
Methods
USING:
accessors
kernel
math
persistent.hashtables.nodes
persistent.hashtables.nodes.bitmap
persistent.sequences
sequences
sequences.private
;
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
;
USING:
accessors
kernel
persistent.hashtables.nodes
persistent.hashtables.nodes.collision
;
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
;
USING:
kernel
persistent.hashtables.nodes
;
M:
empty-node
(pluck-at)
2nip
;
USING:
accessors
kernel
math
persistent.hashtables.config
persistent.hashtables.nodes
persistent.sequences
sequences
;
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
;
USING:
kernel
persistent.hashtables.nodes
persistent.hashtables.nodes.leaf
;
M:
leaf-node
(pluck-at)
[
matching-key?
not
]
1guard
;