From 92afdc3ad0658c1b2d1464be5363dfac734ed060 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 25 Mar 2016 01:52:07 -0700 Subject: [PATCH] hashtables: rename ((tombstone)) to +tombstone+, ((empty)) to +empty+ --- basis/bootstrap/image/image.factor | 2 +- core/bootstrap/primitives.factor | 4 ++-- core/hash-sets/hash-sets.factor | 10 +++++----- core/hashtables/hashtables-docs.factor | 4 ++-- core/hashtables/hashtables.factor | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor index d4975e146a..52ce5c1fee 100755 --- a/basis/bootstrap/image/image.factor +++ b/basis/bootstrap/image/image.factor @@ -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 ; diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 2fbbfdf1c5..6e95f70b2a 100755 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -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 diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index c12be049b1..272c99d858 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -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 : ( n -- array ) - 3 * 1 + 2/ next-power-of-2 ((empty)) ; inline + 3 * 1 + 2/ next-power-of-2 +empty+ ; inline : reset-hash ( n hash -- ) swap >>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 diff --git a/core/hashtables/hashtables-docs.factor b/core/hashtables/hashtables-docs.factor index 08c1dd1101..2a71345be4 100644 --- a/core/hashtables/hashtables-docs.factor +++ b/core/hashtables/hashtables-docs.factor @@ -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 diff --git a/core/hashtables/hashtables.factor b/core/hashtables/hashtables.factor index 0f6ad5919c..24d25e49d0 100644 --- a/core/hashtables/hashtables.factor +++ b/core/hashtables/hashtables.factor @@ -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 : ( n -- array ) - 3 * 1 + 2/ next-power-of-2 2 * ((empty)) ; inline + 3 * 1 + 2/ next-power-of-2 2 * +empty+ ; 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