parent
6f10f06c27
commit
db46b16d10
|
@ -1,17 +1,7 @@
|
|||
! Copyright (C) 2010 Daniel Ehrenberg
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays fry hash-sets hash-sets.private kernel math
|
||||
prettyprint sequences sets sorting tools.test ;
|
||||
FROM: hashtables.private => tombstone ;
|
||||
|
||||
! key@
|
||||
{
|
||||
{ { T{ tombstone } T{ tombstone } } f f }
|
||||
{ { T{ tombstone } 123 } 1 t }
|
||||
} [
|
||||
"hi" 0 <hash-set> key@ 3array
|
||||
123 HS{ 123 } key@ 3array
|
||||
] unit-test
|
||||
USING: accessors fry hash-sets kernel math prettyprint sequences
|
||||
sets sorting tools.test ;
|
||||
|
||||
{ { 1 2 3 } } [ HS{ 1 2 3 } members natural-sort ] unit-test
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ TUPLE: hash-set
|
|||
] if ; inline recursive
|
||||
|
||||
: key@ ( key hash -- array n ? )
|
||||
array>> 2dup hash@ 0 (key@) ; inline
|
||||
array>> dup length>> 0 eq?
|
||||
[ no-key ] [ 2dup hash@ 0 (key@) ] if ; inline
|
||||
|
||||
: <hash-array> ( n -- array )
|
||||
3 * 1 + 2/ next-power-of-2 +empty+ <array> ; inline
|
||||
|
|
|
@ -38,7 +38,8 @@ TUPLE: hashtable
|
|||
] if ; inline recursive
|
||||
|
||||
: key@ ( key hash -- array n ? )
|
||||
array>> 2dup hash@ 0 (key@) ; inline
|
||||
array>> dup length>> 0 eq?
|
||||
[ no-key ] [ 2dup hash@ 0 (key@) ] if ; inline
|
||||
|
||||
: <hash-array> ( n -- array )
|
||||
3 * 1 + 2/ next-power-of-2 2 * +empty+ <array> ; inline
|
||||
|
|
Loading…
Reference in New Issue