--- a/Set.st Wed Jan 29 22:03:53 1997 +0100
+++ b/Set.st Wed Jan 29 22:05:45 1997 +0100
@@ -187,38 +187,31 @@
If it was not in the collection return the value of exceptionBlock.
WARNING: do not remove elements while iterating over the receiver.
- See #saveRemove: to do this."
+ See #saveRemove: to do this."
|index next|
-"/ code below is actually the same as:
-"/
-"/ index := self find:oldObject ifAbsent:[^ exceptionBlock value].
-"/
-"/ but cheaper, since it avoids a block creation,
-"/ making the good case a bit faster.
-
index := self find:oldObject ifAbsent:0.
index == 0 ifTrue:[^ exceptionBlock value].
keyArray basicAt:index put:nil.
tally := tally - 1.
tally == 0 ifTrue:[
- keyArray := self keyContainerOfSize:(self class goodSizeFrom:0).
+ keyArray := self keyContainerOfSize:(self class goodSizeFrom:0).
] ifFalse:[
- index == keyArray basicSize ifTrue:[
- next := 1
- ] ifFalse:[
- next := index + 1.
- ].
- (keyArray basicAt:next) notNil ifTrue:[
- keyArray basicAt:index put:DeletedEntry.
- ].
- self emptyCheck
+ index == keyArray basicSize ifTrue:[
+ next := 1
+ ] ifFalse:[
+ next := index + 1.
+ ].
+ (keyArray basicAt:next) notNil ifTrue:[
+ keyArray basicAt:index put:DeletedEntry.
+ ].
+ self emptyCheck
].
^ oldObject
- "Modified: 1.3.1996 / 21:24:45 / cg"
+ "Modified: 29.1.1997 / 21:34:33 / cg"
!
removeAll
@@ -240,8 +233,9 @@
which is not possible if #remove: is used.
WARNING: since no resizing is done, the physical amount of memory used
- by the container remains the same, although the logical size shrinks.
- You may want to manually resize the receiver using #emptyCheck."
+ by the container remains the same, although the logical size shrinks.
+ You may want to manually resize the receiver using #emptyCheck.
+ (after the loop)"
|index "{ Class:SmallInteger }"
next "{ Class:SmallInteger }"|
@@ -255,63 +249,63 @@
tally := tally - 1.
tally ~~ 0 ifTrue:[
- index == keyArray basicSize ifTrue:[
- next := 1
- ] ifFalse:[
- next := index + 1.
- ].
- (keyArray basicAt:next) notNil ifTrue:[
- keyArray basicAt:index put:DeletedEntry
- ].
+ index == keyArray basicSize ifTrue:[
+ next := 1
+ ] ifFalse:[
+ next := index + 1.
+ ].
+ (keyArray basicAt:next) notNil ifTrue:[
+ keyArray basicAt:index put:DeletedEntry
+ ].
].
^ oldObject
"does NOT work:
- |s|
+ |s|
- s := Set new.
- s add:1.
- s add:2.
- s add:3.
- s add:4.
- s add:5.
- s add:6.
- s add:7.
- s add:8.
- s add:9.
- s do:[:v |
- v odd ifTrue:[
- s remove:v
- ]
- ].
- s inspect
+ s := Set new.
+ s add:1.
+ s add:2.
+ s add:3.
+ s add:4.
+ s add:5.
+ s add:6.
+ s add:7.
+ s add:8.
+ s add:9.
+ s do:[:v |
+ v odd ifTrue:[
+ s remove:v
+ ]
+ ].
+ s inspect
"
"DOES work:
- |s|
+ |s|
- s := Set new.
- s add:1.
- s add:2.
- s add:3.
- s add:4.
- s add:5.
- s add:6.
- s add:7.
- s add:8.
- s add:9.
- s do:[:v |
- v odd ifTrue:[
- s saveRemove:v
- ]
- ].
- s inspect
+ s := Set new.
+ s add:1.
+ s add:2.
+ s add:3.
+ s add:4.
+ s add:5.
+ s add:6.
+ s add:7.
+ s add:8.
+ s add:9.
+ s do:[:v |
+ v odd ifTrue:[
+ s saveRemove:v
+ ]
+ ].
+ s inspect
"
"Created: 1.3.1996 / 21:14:26 / cg"
- "Modified: 1.3.1996 / 21:15:27 / cg"
+ "Modified: 29.1.1997 / 21:35:55 / cg"
! !
!Set methodsFor:'binary storage'!
@@ -681,6 +675,6 @@
!Set class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.43 1997-01-25 13:59:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.44 1997-01-29 21:05:45 cg Exp $'
! !
Set initialize!