added withSize:
authorClaus Gittinger <cg@exept.de>
Wed, 07 May 2003 11:48:30 +0200
changeset 7254 c96b2f224aa2
parent 7253 471856209f4c
child 7255 db63f228cde7
added withSize:
ArrayedCollection.st
--- a/ArrayedCollection.st	Tue May 06 20:27:25 2003 +0200
+++ b/ArrayedCollection.st	Wed May 07 11:48:30 2003 +0200
@@ -273,6 +273,22 @@
     "
 
     "Modified: 13.4.1996 / 12:14:38 / cg"
+!
+
+withSize:size
+    "return a new collection of size.
+     For variable size collections, this is different from #new:,
+     in that #new: creates an empty collection with preallocated size,
+     while #withSize: creates a non empty one."
+
+    ^ self new:size.
+
+    "
+     (OrderedCollection new:10)  
+     (OrderedCollection withSize:10) 
+     (Array new:10) 
+     (Array withSize:10) 
+    "
 ! !
 
 !ArrayedCollection class methodsFor:'queries'!
@@ -438,5 +454,5 @@
 !ArrayedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.52 2002-09-10 15:29:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.53 2003-05-07 09:48:30 cg Exp $'
 ! !