added #clearContents:
authorca
Tue, 07 Apr 1998 13:39:08 +0200
changeset 632 7008f9f8ad20
parent 631 3423da7cf851
child 633 baa3e20e50b2
added #clearContents:
List.st
--- a/List.st	Tue Apr 07 09:54:19 1998 +0200
+++ b/List.st	Tue Apr 07 13:39:08 1998 +0200
@@ -173,6 +173,25 @@
     "Created: / 26.1.1998 / 11:10:55 / cg"
 !
 
+clearContents
+    "remove all elements from the collection but keep the contentsArray.
+     Useful for huge lists, if the contents will be rebuild soon (using #add:) 
+     to a size which is similar to the lists current size.
+     Returns the receiver."
+
+     |prevSize|
+
+     prevSize := self size.
+     super clearContents.
+
+     prevSize ~~ 0 ifTrue:[
+        dependents notNil ifTrue:[
+            self changed:#removeFrom: with:(Array with:1 with:prevSize)
+        ]
+     ]
+
+!
+
 removeAll
     "remove all elements from the collection.
      Returns the receiver."
@@ -322,5 +341,5 @@
 !List class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/List.st,v 1.10 1998-02-02 18:07:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/List.st,v 1.11 1998-04-07 11:39:08 ca Exp $'
 ! !