--- a/Set.st Thu Aug 11 06:44:08 2016 +0200
+++ b/Set.st Fri Aug 12 06:44:59 2016 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
@@ -202,7 +200,6 @@
"Created: / 24.10.1997 / 23:13:44 / cg"
! !
-
!Set methodsFor:'Compatibility-ST80'!
initialIndexFor:hashKey boundedBy:length
@@ -816,6 +813,7 @@
! !
+
!Set methodsFor:'obsolete set operations'!
+ aCollection
@@ -935,6 +933,59 @@
"Modified: / 27-02-2011 / 15:30:42 / cg"
!
+findKeyOrNilOrDeletedEntry:key
+ "Look for the key in the receiver.
+ If it is found, return the index of the first unused slot.
+ Grow the receiver, if key was not found, and no unused slots were present.
+ The answer is the index into the keyArray where the (keyArray at:index)
+ may contain:
+ nil - an empty slot
+ DeletedEntry - an empty slot, but preceeded and followed by non-empty
+ slots with keys hashing to the same value (hash collisions)
+ key - key is laready present in the slot."
+
+ |index "{ Class:SmallInteger }"
+ length "{ Class:SmallInteger }"
+ startIndex probe
+ delIndex "{ Class:SmallInteger }"|
+
+ delIndex := 0.
+
+ length := keyArray basicSize.
+ startIndex := index := self initialIndexForKey:key.
+
+ [
+ probe := keyArray basicAt:index.
+ probe isNil ifTrue:[
+ delIndex == 0 ifTrue:[^ index].
+ ^ delIndex
+ ].
+ probe == DeletedEntry ifTrue:[
+ delIndex == 0 ifTrue:[
+ delIndex := index
+ ]
+ ] ifFalse:[
+ key = probe ifTrue:[^ index]
+ ].
+
+ index == length ifTrue:[
+ index := 1
+ ] ifFalse:[
+ index := index + 1
+ ].
+ index == startIndex ifTrue:[
+ delIndex ~~ 0 ifTrue:[
+ ^ delIndex
+ ].
+ self grow.
+ length := keyArray basicSize.
+ startIndex := index := self initialIndexForKey:key.
+ ].
+ ] loop.
+
+ "Modified: / 27-02-2011 / 15:30:42 / cg"
+!
+
findNil:key
"Look for the next slot usable for key.
WARNING: