Merge branch 'master' of git://factorcode.org/git/factor
commit
f00ff8813d
|
@ -95,11 +95,12 @@ IN: hashtables
|
|||
[ swap pick (set-hash) drop f ] find-pair 2drop 2drop ;
|
||||
|
||||
: hash-large? ( hash -- ? )
|
||||
dup hash-count 3 fixnum*fast
|
||||
swap hash-array array-capacity > ;
|
||||
[ hash-count 3 fixnum*fast ]
|
||||
[ hash-array array-capacity ] bi > ;
|
||||
|
||||
: hash-stale? ( hash -- ? )
|
||||
dup hash-deleted 10 fixnum*fast swap hash-count fixnum> ;
|
||||
[ hash-deleted 10 fixnum*fast ]
|
||||
[ hash-count ] bi fixnum> ;
|
||||
|
||||
: grow-hash ( hash -- )
|
||||
[ dup hash-array swap assoc-size 1+ ] keep
|
||||
|
@ -183,10 +184,13 @@ M: hashtable assoc-like
|
|||
[ 3drop ] [ dupd dupd set-at swap push ] if ; inline
|
||||
|
||||
: prune ( seq -- newseq )
|
||||
dup length <hashtable> over length <vector>
|
||||
rot [ >r 2dup r> (prune) ] each nip ;
|
||||
[ length <hashtable> ]
|
||||
[ length <vector> ]
|
||||
[ ] tri
|
||||
[ >r 2dup r> (prune) ] each nip ;
|
||||
|
||||
: all-unique? ( seq -- ? )
|
||||
dup prune [ length ] 2apply = ;
|
||||
[ length ]
|
||||
[ prune length ] bi = ;
|
||||
|
||||
INSTANCE: hashtable assoc
|
||||
|
|
|
@ -17,7 +17,7 @@ HELP: random-32*
|
|||
{ $description "Generates a random 32-bit unsigned integer." } ;
|
||||
|
||||
HELP: random-bytes*
|
||||
{ $values { "n" "an integer" } { "tuple" "a random number generator" } { "bytes" "a sequence of random bytes" } }
|
||||
{ $values { "n" "an integer" } { "tuple" "a random number generator" } { "byte-array" "a sequence of random bytes" } }
|
||||
{ $description "Generates a byte-array of random bytes." } ;
|
||||
|
||||
HELP: random
|
||||
|
@ -26,7 +26,7 @@ HELP: random
|
|||
{ $notes "Since integers are sequences, passing an integer " { $snippet "n" } " yields a random integer in the interval " { $snippet "[0,n)" } "." } ;
|
||||
|
||||
HELP: random-bytes
|
||||
{ $values { "n" "an integer" } { "bytes" "a random integer" } }
|
||||
{ $values { "n" "an integer" } { "byte-array" "a random integer" } }
|
||||
{ $description "Outputs an integer with n bytes worth of bits." } ;
|
||||
|
||||
HELP: random-bits
|
||||
|
|
Loading…
Reference in New Issue