Cleanup
parent
d7742af90e
commit
db7939d68c
|
@ -18,14 +18,9 @@ IN: hashtables
|
||||||
: (key@) ( key keys i -- array n ? )
|
: (key@) ( key keys i -- array n ? )
|
||||||
3dup swap array-nth
|
3dup swap array-nth
|
||||||
dup ((empty)) eq?
|
dup ((empty)) eq?
|
||||||
[ 3drop nip f f ]
|
[ 3drop nip f f ] [
|
||||||
[
|
= [ rot drop t ] [ probe (key@) ] if
|
||||||
=
|
] if ; inline
|
||||||
[ rot drop t ]
|
|
||||||
[ probe (key@) ]
|
|
||||||
if
|
|
||||||
]
|
|
||||||
if ; inline
|
|
||||||
|
|
||||||
: key@ ( key hash -- array n ? )
|
: key@ ( key hash -- array n ? )
|
||||||
hash-array 2dup hash@ (key@) ; inline
|
hash-array 2dup hash@ (key@) ; inline
|
||||||
|
@ -89,7 +84,8 @@ IN: hashtables
|
||||||
] if
|
] if
|
||||||
] if ; inline
|
] if ; inline
|
||||||
|
|
||||||
: find-pair ( array quot -- key value ? ) 0 rot (find-pair) ; inline
|
: find-pair ( array quot -- key value ? )
|
||||||
|
0 rot (find-pair) ; inline
|
||||||
|
|
||||||
: (rehash) ( hash array -- )
|
: (rehash) ( hash array -- )
|
||||||
[ swap pick (set-hash) drop f ] find-pair 2drop 2drop ;
|
[ swap pick (set-hash) drop f ] find-pair 2drop 2drop ;
|
||||||
|
@ -99,8 +95,7 @@ IN: hashtables
|
||||||
[ hash-array array-capacity ] bi > ;
|
[ hash-array array-capacity ] bi > ;
|
||||||
|
|
||||||
: hash-stale? ( hash -- ? )
|
: hash-stale? ( hash -- ? )
|
||||||
[ hash-deleted 10 fixnum*fast ]
|
[ hash-deleted 10 fixnum*fast ] [ hash-count ] bi fixnum> ;
|
||||||
[ hash-count ] bi fixnum> ;
|
|
||||||
|
|
||||||
: grow-hash ( hash -- )
|
: grow-hash ( hash -- )
|
||||||
[ dup hash-array swap assoc-size 1+ ] keep
|
[ dup hash-array swap assoc-size 1+ ] keep
|
||||||
|
@ -185,12 +180,12 @@ M: hashtable assoc-like
|
||||||
|
|
||||||
: prune ( seq -- newseq )
|
: prune ( seq -- newseq )
|
||||||
[ length <hashtable> ]
|
[ length <hashtable> ]
|
||||||
[ length <vector> ]
|
[ length <vector> ]
|
||||||
[ ] tri
|
[ ] tri
|
||||||
[ >r 2dup r> (prune) ] each nip ;
|
[ >r 2dup r> (prune) ] each nip ;
|
||||||
|
|
||||||
: all-unique? ( seq -- ? )
|
: all-unique? ( seq -- ? )
|
||||||
[ length ]
|
[ length ]
|
||||||
[ prune length ] bi = ;
|
[ prune length ] bi = ;
|
||||||
|
|
||||||
INSTANCE: hashtable assoc
|
INSTANCE: hashtable assoc
|
||||||
|
|
Loading…
Reference in New Issue