added removeAll
authorclaus
Mon, 22 Aug 1994 14:28:49 +0200
changeset 134 c96945f0aa1d
parent 133 433d44af1630
child 135 077f485d7783
added removeAll
Coll.st
Collection.st
--- a/Coll.st	Mon Aug 22 14:21:33 1994 +0200
+++ b/Coll.st	Mon Aug 22 14:28:49 1994 +0200
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/Attic/Coll.st,v 1.14 1994-08-05 00:54:16 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Attic/Coll.st,v 1.15 1994-08-22 12:28:49 claus Exp $
 '!
 
 !Collection class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/Attic/Coll.st,v 1.14 1994-08-05 00:54:16 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Attic/Coll.st,v 1.15 1994-08-22 12:28:49 claus Exp $
 "
 !
 
@@ -168,7 +168,7 @@
 errorInvalidKey
     "report an error that the given key was invalid"
 
-    InvalidKeySignal raise
+    ^ InvalidKeySignal raise
 ! !
 
 !Collection methodsFor:'accessing'!
@@ -288,6 +288,16 @@
     self remove:anObject ifAbsent:[self errorNotFound]
 !
 
+removeAll
+    "remove all elements from the receiver.
+     This should be reimplemented in subclasses for better
+     performance."
+
+    [self notEmpty] whileTrue:[
+        self removeFirst
+    ].
+!
+
 removeAll:aCollection
     "remove all elements of the argument, aCollection from the receiver"
 
--- a/Collection.st	Mon Aug 22 14:21:33 1994 +0200
+++ b/Collection.st	Mon Aug 22 14:28:49 1994 +0200
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.14 1994-08-05 00:54:16 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.15 1994-08-22 12:28:49 claus Exp $
 '!
 
 !Collection class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.14 1994-08-05 00:54:16 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.15 1994-08-22 12:28:49 claus Exp $
 "
 !
 
@@ -168,7 +168,7 @@
 errorInvalidKey
     "report an error that the given key was invalid"
 
-    InvalidKeySignal raise
+    ^ InvalidKeySignal raise
 ! !
 
 !Collection methodsFor:'accessing'!
@@ -288,6 +288,16 @@
     self remove:anObject ifAbsent:[self errorNotFound]
 !
 
+removeAll
+    "remove all elements from the receiver.
+     This should be reimplemented in subclasses for better
+     performance."
+
+    [self notEmpty] whileTrue:[
+        self removeFirst
+    ].
+!
+
 removeAll:aCollection
     "remove all elements of the argument, aCollection from the receiver"