--- a/IdentitySet.st Wed Feb 15 11:22:05 1995 +0100
+++ b/IdentitySet.st Wed Feb 15 11:24:31 1995 +0100
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1993 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -11,17 +11,17 @@
"
Set subclass:#IdentitySet
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Unordered'
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Unordered'
!
IdentitySet comment:'
COPYRIGHT (c) 1993 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/IdentitySet.st,v 1.9 1994-08-05 00:54:57 claus Exp $
+$Header: /cvs/stx/stx/libbasic/IdentitySet.st,v 1.10 1995-02-15 10:24:26 claus Exp $
'!
!IdentitySet class methodsFor:'documentation'!
@@ -29,7 +29,7 @@
copyright
"
COPYRIGHT (c) 1993 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/IdentitySet.st,v 1.9 1994-08-05 00:54:57 claus Exp $
+$Header: /cvs/stx/stx/libbasic/IdentitySet.st,v 1.10 1995-02-15 10:24:26 claus Exp $
"
!
@@ -68,33 +68,36 @@
length := keyArray basicSize.
length < 10 ifTrue:[
- "assuming, that for small sets the overhead of hashing
- is large ..."
- ^ keyArray identityIndexOf:key ifAbsent:aBlock.
+ "assuming, that for small sets the overhead of hashing
+ is large ..."
+ ^ keyArray identityIndexOf:key ifAbsent:aBlock.
].
startIndex := key identityHash \\ length + 1.
index := startIndex.
[true] whileTrue:[
- probe := (keyArray basicAt:index).
- probe == key ifTrue:[^ index].
- probe isNil ifTrue:[^ aBlock value].
+ probe := (keyArray basicAt:index).
+ probe == key ifTrue:[^ index].
+ probe isNil ifTrue:[^ aBlock value].
- index == length ifTrue:[
- index := 1
- ] ifFalse:[
- index := index + 1
- ].
- index == startIndex ifTrue:[
- ^ aBlock value
- ]
+ index == length ifTrue:[
+ index := 1
+ ] ifFalse:[
+ index := index + 1
+ ].
+ index == startIndex ifTrue:[
+ ^ aBlock value
+ ]
]
!
findKeyOrNil:key
- "Look for the key in the receiver. Redefined to compare for
- identity instead of equality"
+ "Look for the key in the receiver. If it is found, return
+ the index of the slot containing the key, otherwise
+ return the index of the first unused slot. Grow the receiver,
+ if key was not found, and no unused slots where present.
+ Redefined to compare for identity instead of equality"
|index "{ Class:SmallInteger }"
length startIndex probe |
@@ -104,22 +107,21 @@
index := startIndex.
[true] whileTrue:[
- probe := keyArray basicAt:index.
- (probe isNil or: [key == probe]) ifTrue:[^ index].
- probe == DeletedEntry ifTrue:[
- keyArray basicAt:index put:nil.
- ^ index
- ].
-"/ (probe isNil or: [key == probe]) ifTrue:[^ index].
+ probe := keyArray basicAt:index.
+ (probe isNil or: [key == probe]) ifTrue:[^ index].
+ probe == DeletedEntry ifTrue:[
+ keyArray basicAt:index put:nil.
+ ^ index
+ ].
- index == length ifTrue:[
- index := 1
- ] ifFalse:[
- index := index + 1
- ].
- index == startIndex ifTrue: [
- ^ self grow findElementOrNil:key
- ]
+ index == length ifTrue:[
+ index := 1
+ ] ifFalse:[
+ index := index + 1
+ ].
+ index == startIndex ifTrue: [
+ ^ self grow findKeyOrNil:key
+ ]
]
!
@@ -134,13 +136,13 @@
index := key identityHash \\ length + 1.
[(keyArray basicAt:index) notNil] whileTrue:[
- index == length ifTrue:[
- index := 1
- ] ifFalse:[
- index := index + 1
- ].
- "notice: no check for no nil found - we must find one since
- this is only called after growing"
+ index == length ifTrue:[
+ index := 1
+ ] ifFalse:[
+ index := index + 1
+ ].
+ "notice: no check for no nil found - we must find one since
+ this is only called after growing"
].
^ index