IdentitySet.st
changeset 19546 48d60cfe82b9
parent 16240 aa502d6cbe9e
child 19559 d35a89d5c0ec
child 20234 1b1281334a9a
--- a/IdentitySet.st	Tue Apr 05 20:48:39 2016 +0200
+++ b/IdentitySet.st	Tue Apr 05 20:50:31 2016 +0200
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libbasic' }"
 
+"{ NameSpace: Smalltalk }"
+
 Set subclass:#IdentitySet
 	instanceVariableNames:''
 	classVariableNames:''
@@ -115,8 +117,8 @@
     count := 0.
     [
         probe := keyArray basicAt:index.
-        (probe notNil and:[key == probe]) ifTrue:[^ count].
-        (self slotIsEmpty:probe) ifTrue:[self error:'non existing key'].
+        probe isNil ifTrue:[self error:'non existing key'].
+        key == probe ifTrue:[^ count].
 
         index == length ifTrue:[
             index := 1.
@@ -153,7 +155,7 @@
     [
         probe := keyArray basicAt:index.
         probe == key ifTrue:[^ index].        "<<<< == is different from inherited"
-        (self slotIsEmpty:probe) ifTrue:[^ aBlock value].
+        probe isNil ifTrue:[^ aBlock value].
 
         index == length ifTrue:[
             index := 1
@@ -175,12 +177,15 @@
 findKeyOrNil:key
     "Look for the key in the receiver.  
      If it is found, return return the index of the first unused slot. 
-     Grow the receiver, if key was not found, and no unused slots were present"
+     Grow the receiver, if key was not found, and no unused slots were present
+
+     Warning: an empty slot MUST be filled by the sender - it is only to be sent
+              by at:put: / add: - like methods."
 
     |index  "{ Class:SmallInteger }"
      length "{ Class:SmallInteger }"
      startIndex probe 
-     delIndex "{ Class:SmallInteger }" |
+     delIndex "{ Class:SmallInteger }"|
 
     delIndex := 0.
 
@@ -190,7 +195,7 @@
     [
         probe := keyArray basicAt:index.
         key == probe ifTrue:[^ index].
-        (self slotIsEmpty:probe) ifTrue:[
+        probe isNil ifTrue:[
             delIndex == 0 ifTrue:[^ index].
             keyArray basicAt:delIndex put:nil.
             ^ delIndex
@@ -283,6 +288,6 @@
 !IdentitySet class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/IdentitySet.st,v 1.38 2014-03-07 22:06:33 stefan Exp $'
+    ^ '$Header$'
 ! !