added: #next: - tuning
authorClaus Gittinger <cg@exept.de>
Thu, 08 Oct 2009 10:43:59 +0200
changeset 12176 44e86cdc5798
parent 12175 d22d131dbfed
child 12177 63eb5d728567
added: #next: - tuning
ReadStream.st
--- a/ReadStream.st	Thu Oct 08 10:19:46 2009 +0200
+++ b/ReadStream.st	Thu Oct 08 10:43:59 2009 +0200
@@ -55,7 +55,6 @@
     ^ super with:aCollection
 ! !
 
-
 !ReadStream methodsFor:'converting'!
 
 readStream
@@ -197,6 +196,29 @@
     ^ ret
 !
 
+next:count
+    "return the next count elements of the stream as aCollection,
+     which depends on the streams type - (see #contentsSpecies)."
+
+    |answer|
+
+    self contentsSpecies = collection class ifTrue:[
+        ((position + count - ZeroPosition) > readLimit) ifFalse:[
+            answer := collection copyFrom:position+1 to:position+count.
+            position := position+count.
+            ^ answer
+        ].
+    ].
+    ^ super next:count
+
+    "
+     #[1 2 3 4 5 6 7 8 9] readStream
+        next;      
+        next:5;    
+        next.
+    "
+!
+
 nextAlphaNumericWord
     "read the next word (i.e. up to non letter-or-digit).
      return a string containing those characters.
@@ -806,5 +828,9 @@
 !ReadStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.62 2007-06-05 16:20:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.63 2009-10-08 08:43:59 cg Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.63 2009-10-08 08:43:59 cg Exp $'
 ! !