SequenceableCollection.st
branchjv
changeset 19861 95c7068e30ba
parent 19812 0866264d6eed
parent 19819 e7676f4fed11
child 19862 6c010853ea32
--- a/SequenceableCollection.st	Fri May 13 20:17:32 2016 +0200
+++ b/SequenceableCollection.st	Sat May 14 09:34:43 2016 +0200
@@ -299,6 +299,26 @@
     ^ stream contents
 !
 
+new:initialSize withCollectedContents:blockWithArg
+    "create an instance of the receiver-class,
+     evaluate blockWithArg, passing that instance,
+     return the instance.
+     Similar to streamContents, but passes the collection to the block,
+     instead of a stream."
+
+    |inst|
+
+    inst := self new:initialSize.
+    blockWithArg value:inst.
+    ^ inst
+
+    "
+     |rslt|
+
+     rslt := OrderedCollection new:10 withCollectedContents:[:c | c add:'hello'; add:'world']
+    "
+!
+
 streamContents:blockWithArg
     "create a write-stream on an instance of the receiver-class,
      evaluate blockWithArg, passing that stream,
@@ -374,6 +394,26 @@
     "Created: / 29-03-2007 / 15:05:30 / cg"
 !
 
+withCollectedContents:blockWithArg
+    "create an instance of the receiver-class,
+     evaluate blockWithArg, passing that instance,
+     return the instance.
+     Similar to streamContents, but passes the collection to the block,
+     instead of a stream."
+
+    |inst|
+
+    inst := self new.
+    blockWithArg value:inst.
+    ^ inst
+
+    "
+     |rslt|
+
+     rslt := OrderedCollection withCollectedContents:[:c | c add:'hello'; add:'world']
+    "
+!
+
 writeStream
     "create a write-stream on an instance of the receiver-class"