|
|
6.113 PositionableStream
- Defined in namespace Smalltalk
- Category: Streams-Collections
- My instances represent streams where explicit positioning is permitted.
Thus, my streams act in a manner to normal disk files: you can read
or write sequentially, but also position the file to a particular place
whenever you choose. Generally, you'll want to use ReadStream, WriteStream
or ReadWriteStream instead of me to create and use streams.
6.113.1 PositionableStream class: instance creation
- on: aCollection
- Answer an instance of the receiver streaming on the whole contents of aCollection
- on: aCollection from: firstIndex to: lastIndex
- Answer an instance of the receiver streaming from the firstIndex-th item of aCollection to the lastIndex-th
6.113.2 PositionableStream: accessing-reading
- close
- Disassociate a stream from its backing store.
- contents
- Returns a collection of the same type that the stream accesses, up to and including the final element.
- copyFrom: start to: end
- Answer the collection on which the receiver is streaming, from the start-th item to the end-th
- next
- Answer the next item of the receiver
- peek
- Returns the next element of the stream without moving the pointer. Returns nil when at end of stream.
- peekFor: anObject
- Returns true and gobbles the next element from the stream of it is equal to anObject, returns false and doesn't gobble the next element if the next element is not equal to anObject.
- reverseContents
- Returns a collection of the same type that the stream accesses, up to and including the final element, but in reverse order.
6.113.3 PositionableStream: class type methods
- isExternalStream
- We stream on a collection residing in the image, so answer false
- species
- The collections returned by #upTo: etc. are the same kind as those returned by the collection with methods such as #select:
6.113.4 PositionableStream: positioning
- basicPosition: anInteger
- Move the stream pointer to the anInteger-th object
- position
- Answer the current value of the stream pointer
- position: anInteger
- Move the stream pointer to the anInteger-th object
- reset
- Move the stream back to its first element. For write-only streams, the stream is truncated there.
- setToEnd
- Move the current position to the end of the stream.
- size
- Answer the size of data on which we are streaming.
- skip: anInteger
- Move the current position by anInteger places, either forwards or backwards.
- skipSeparators
- Advance the receiver until we find a character that is not a separator. Answer false if we reach the end of the stream, else answer true; in this case, sending #next will return the first non-separator character (possibly the same to which the stream pointed before #skipSeparators was sent).
6.113.5 PositionableStream: testing
- atEnd
- Answer whether the objects in the stream have reached an end
- basicAtEnd
- Answer whether the objects in the stream have reached an end. This method must NOT be overridden.
- isEmpty
- Answer whether the stream has no objects
6.113.6 PositionableStream: truncating
- truncate
- Truncate the receiver to the current position - only valid for writing streams
|