hash-sets: faster members.
							parent
							
								
									7d489d5839
								
							
						
					
					
						commit
						aeed8b51d4
					
				|  | @ -1,9 +1,10 @@ | |||
| ! 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 | ||||
|  | @ -71,7 +72,7 @@ TUPLE: hash-set | |||
|     [ count>> 3 fixnum*fast ] | ||||
|     [ array>> length>> 1 fixnum-shift-fast ] bi fixnum>= ; inline | ||||
| 
 | ||||
| : each-member ( array quot: ( elt -- ) -- ) | ||||
| : each-member ( ... array quot: ( ... elt -- ... ) -- ... ) | ||||
|     [ if ] curry [ dup tombstone? [ drop ] ] prepose each ; inline | ||||
| 
 | ||||
| : grow-hash ( hash -- ) | ||||
|  | @ -116,9 +117,9 @@ M: hash-set ?adjoin | |||
|     dup ?grow-hash (adjoin) ; | ||||
| 
 | ||||
| M: hash-set members | ||||
|     [ array>> ] [ cardinality <vector> ] bi [ | ||||
|         [ push-unsafe ] curry each-member | ||||
|     ] keep { } like ; | ||||
|     [ 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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue