PositionableStream.st
changeset 22003 1a4affe1e22c
parent 21136 fc36f8c599ce
child 22204 189b58c6ed87
equal deleted inserted replaced
22002:a56e43b3b432 22003:1a4affe1e22c
   834     peekObject := self next.
   834     peekObject := self next.
   835     self backStep.
   835     self backStep.
   836     ^ peekObject
   836     ^ peekObject
   837 !
   837 !
   838 
   838 
       
   839 peek:n
       
   840     "look ahead n elements and return them after positioning pack to the 
       
   841      position we had before"
       
   842 
       
   843     |posBefore peekObjects|
       
   844 
       
   845     posBefore := self position.
       
   846     peekObjects := self next:n.
       
   847     self position:posBefore.
       
   848     ^ peekObjects
       
   849 
       
   850     "
       
   851      |s|
       
   852 
       
   853      s := '1234567890' readStream.
       
   854      s peek:4.
       
   855      s next:5.
       
   856     "
       
   857 
       
   858     "Created: / 13-07-2017 / 12:32:03 / cg"
       
   859 !
       
   860 
   839 upToAll:aCollection
   861 upToAll:aCollection
   840     "read until a subcollection consisisting of the elements in aCollection is encountered.
   862     "read until a subcollection consisisting of the elements in aCollection is encountered.
   841      Return everything read excluding the elements in aCollection.
   863      Return everything read excluding the elements in aCollection.
   842      The position is left before the collection; i.e. the next
   864      The position is left before the collection; i.e. the next
   843      read operations will return those elements.
   865      read operations will return those elements.