#REFACTORING by stefan
class: IdentityDictionary
changed:
#find:ifAbsent:
#findKeyOrNil:
--- a/IdentityDictionary.st Tue Apr 05 20:50:31 2016 +0200
+++ b/IdentityDictionary.st Tue Apr 05 20:51:17 2016 +0200
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libbasic' }"
+"{ NameSpace: Smalltalk }"
+
Dictionary subclass:#IdentityDictionary
instanceVariableNames:''
classVariableNames:''
@@ -97,7 +99,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
@@ -110,13 +112,16 @@
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"
+ 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
+
+ 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.
@@ -125,8 +130,8 @@
[
probe := keyArray basicAt:index.
- key == probe ifTrue:[^ index].
- (self slotIsEmpty:probe) ifTrue:[
+ key == probe ifTrue:[^ index]. "<<<< == is different from inherited"
+ probe isNil ifTrue:[
delIndex == 0 ifTrue:[^ index].
keyArray basicAt:delIndex put:nil.
^ delIndex
@@ -192,6 +197,6 @@
!IdentityDictionary class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/IdentityDictionary.st,v 1.31 2014-03-07 22:07:13 stefan Exp $'
+ ^ '$Header$'
! !