 ! Copyright (C) 2010 Daniel Ehrenberg
 ! Copyright (C) 2005, 2011 John Benediktsson, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays hash-sets hashtables.private kernel
-kernel.private math math.private sequences sequences.private
-sets sets.private slots.private vectors ;
+USING: accessors arrays growable.private hash-sets
+hashtables.private kernel kernel.private math math.private
+sequences sequences.private sets sets.private slots.private
+vectors ;
 IN: hash-sets
 
 TUPLE: hash-set

    [ count>> 3 fixnum*fast ]
    [ array>> length>> 1 fixnum-shift-fast ] bi fixnum>= ; inline

: each-member ( array quot: ( elt -- ) -- )
    [ if ] curry [ dup tombstone? [ drop ] ] prepose each ; inline

: grow-hash ( hash -- )

    dup ?grow-hash (adjoin) ;

M: hash-set members
    [ array>> 0 swap ] [ cardinality f <array> ] bi [
        [ [ over ] dip set-nth-unsafe 1 + ] curry each-member
    ] keep nip ;

M: hash-set clone
    (clone) [ clone ] change-array ; inline
