]> gitweb.factorcode.org Git - factor.git/commitdiff
hashtables: rename ((tombstone)) to +tombstone+, ((empty)) to +empty+
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 25 Mar 2016 08:52:07 +0000 (01:52 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 25 Mar 2016 10:13:27 +0000 (03:13 -0700)
basis/bootstrap/image/image.factor
core/bootstrap/primitives.factor
core/hash-sets/hash-sets.factor
core/hashtables/hashtables-docs.factor
core/hashtables/hashtables.factor

index d4975e146a22feffd42803d6a34c65f52d9cca4b..52ce5c1fee57c727fd870ef6a41de3d8990cf790 100755 (executable)
@@ -375,7 +375,7 @@ ERROR: tuple-removed class ;
 M: tuple prepare-object emit-tuple ;
 
 M: tombstone prepare-object
-    state>> "((tombstone))" "((empty))" ?
+    state>> "+tombstone+" "+empty+" ?
     "hashtables.private" lookup-word def>> first
     [ emit-tuple ] cache-eql-object ;
 
index 2fbbfdf1c5965a09ddc98aff05a58a16a1e3d0d4..6e95f70b2ab3f740946e1303b046c783ffba448e 100755 (executable)
@@ -265,11 +265,11 @@ bi
 tuple
 { "state" } define-tuple-class
 
-"((empty))" "hashtables.private" create-word
+"+empty+" "hashtables.private" create-word
 { f } "tombstone" "hashtables.private" lookup-word
 slots>tuple 1quotation ( -- value ) define-inline
 
-"((tombstone))" "hashtables.private" create-word
+"+tombstone+" "hashtables.private" create-word
 { t } "tombstone" "hashtables.private" lookup-word
 slots>tuple 1quotation ( -- value ) define-inline
 
index c12be049b1c719714e20decc5ab41c81cf8fd2a4..272c99d85876a263aba27968232664db3d04501d 100644 (file)
@@ -23,7 +23,7 @@ TUPLE: hash-set
 : no-key ( key array -- array n ? ) nip f f ; inline
 
 : (key@) ( key array i probe# -- array n ? )
-    [ 3dup swap array-nth ] dip over ((empty)) eq?
+    [ 3dup swap array-nth ] dip over +empty+ eq?
     [ 4drop no-key ] [
         [ = ] dip swap
         [ drop rot drop t ]
@@ -36,7 +36,7 @@ TUPLE: hash-set
     [ no-key ] [ 2dup hash@ 0 (key@) ] if ; inline
 
 : <hash-array> ( n -- array )
-    3 * 1 + 2/ next-power-of-2 ((empty)) <array> ; inline
+    3 * 1 + 2/ next-power-of-2 +empty+ <array> ; inline
 
 : reset-hash ( n hash -- )
     swap <hash-array> >>array init-hash ; inline
@@ -44,7 +44,7 @@ TUPLE: hash-set
 : (new-key@) ( key array i probe# j -- array i j empty? )
     [ 2dup swap array-nth ] 2dip pick tombstone?
     [
-        rot ((empty)) eq?
+        rot +empty+ eq?
         [ nip [ drop ] 3dip t ]
         [ pick or [ probe ] dip (new-key@) ]
         if
@@ -95,11 +95,11 @@ M: hash-set in?
      key@ 2nip ;
 
 M: hash-set clear-set
-    [ init-hash ] [ array>> [ drop ((empty)) ] map! drop ] bi ;
+    [ init-hash ] [ array>> [ drop +empty+ ] map! drop ] bi ;
 
 M: hash-set delete
     [ nip ] [ key@ ] 2bi [
-        [ ((tombstone)) ] 2dip set-nth-item
+        [ +tombstone+ ] 2dip set-nth-item
         hash-deleted+
     ] [
         3drop
index 08c1dd11016d873bc88b5bcb20020bbd4ed25e32..2a71345be4d5ea38ac4201234f3662391a630a84 100644 (file)
@@ -5,7 +5,7 @@ IN: hashtables
 ARTICLE: "hashtables.private" "Hashtable implementation details"
 "This hashtable implementation uses only one auxiliary array in addition to the hashtable tuple itself. The array stores keys in even slots and values in odd slots. Values are looked up with a hashing strategy that uses quadratic probing to resolve collisions."
 $nl
-"There are two special objects: the " { $link ((tombstone)) } " marker and the " { $link ((empty)) } " marker. Neither of these markers can be used as hashtable keys."
+"There are two special objects: the " { $link +tombstone+ } " marker and the " { $link +empty+ } " marker. Neither of these markers can be used as hashtable keys."
 $nl
 "The " { $snippet "count" } " slot is the number of entries including deleted entries, and " { $snippet "deleted" } " is the number of deleted entries."
 { $subsections
@@ -70,7 +70,7 @@ HELP: probe
 
 HELP: key@
 { $values { "key" "a key" } { "hash" hashtable } { "array" "the underlying array of the hashtable" } { "n" "the index of the key" } { "?" "a boolean indicating whether the key was present" } }
-{ $description "Searches the hashtable for the key using a quadratic probing strategy. Searches stop if either the key or an " { $link ((empty)) } " sentinel is found. Searches skip the " { $link ((tombstone)) } " sentinel." } ;
+{ $description "Searches the hashtable for the key using a quadratic probing strategy. Searches stop if either the key or an " { $link +empty+ } " sentinel is found. Searches skip the " { $link +tombstone+ } " sentinel." } ;
 
 { key@ new-key@ } related-words
 
index 0f6ad5919cd749b9a648a84910b2d23162e63dc8..24d25e49d00b560ad5e355f817827977e8382af6 100644 (file)
@@ -23,7 +23,7 @@ TUPLE: hashtable
 : no-key ( key array -- array n ? ) nip f f ; inline
 
 : (key@) ( key array i probe# -- array n ? )
-    [ 3dup swap array-nth ] dip over ((empty)) eq?
+    [ 3dup swap array-nth ] dip over +empty+ eq?
     [ 4drop no-key ] [
         [ = ] dip swap
         [ drop rot drop t ]
@@ -36,7 +36,7 @@ TUPLE: hashtable
     [ no-key ] [ 2dup hash@ 0 (key@) ] if ; inline
 
 : <hash-array> ( n -- array )
-    3 * 1 + 2/ next-power-of-2 2 * ((empty)) <array> ; inline
+    3 * 1 + 2/ next-power-of-2 2 * +empty+ <array> ; inline
 
 : init-hash ( hash -- )
     0 >>count 0 >>deleted drop ; inline
@@ -68,7 +68,7 @@ TUPLE: hashtable
 : (new-key@) ( key array i probe# j -- array i j empty? )
     [ 2dup swap array-nth ] 2dip pick tombstone?
     [
-        rot ((empty)) eq?
+        rot +empty+ eq?
         [ nip [ drop ] 3dip t ]
         [ pick or [ probe ] dip (new-key@) ]
         if
@@ -126,11 +126,11 @@ M: hashtable at*
     key@ [ 3 fixnum+fast slot t ] [ 2drop f f ] if ;
 
 M: hashtable clear-assoc
-    [ init-hash ] [ array>> [ drop ((empty)) ] map! drop ] bi ;
+    [ init-hash ] [ array>> [ drop +empty+ ] map! drop ] bi ;
 
 M: hashtable delete-at
     [ nip ] [ key@ ] 2bi [
-        [ ((tombstone)) dup ] 2dip set-nth-pair
+        [ +tombstone+ dup ] 2dip set-nth-pair
         hash-deleted+
     ] [
         3drop