Next: stream_views ; view_stream
Up: Input/output
Previous: Input/output
Index
In stream.diesel:
A stream is like a collection of values, but the values are accessed
in sequence. Streams have an implicit position within the stream of
values, pointing between two values (or before the first value or
after the last value), and operations on streams are relative to
this implicit position.
The basic stream data type supports forward reading of a stream of
values. The at_end
and before_end
testers check whether the current
position is after the last value in the stream. The forward
operation advances the position past the next value in the
stream. The next operation reads and returns the next value in the
stream, advancing the position as a side-effect; the next_N
operation reads and returns the next N elements of the stream. The
peek_next
operation reads and returns the next element of the stream
but does not advance the position; a subsequent next or peek_next
operation will return the same value.
abstract class stream[T] isa stream[`S >= T];
fun is_at_end(:stream[`T]):bool;
fun before_end(s:stream[`T]):bool;
fun forward(:stream[`T], at_end:&():void):void;
fun forward(s:stream[`T]):void;
fun next(:stream[`T], at_end:&():`S):T|S;
fun next(s:stream[`T]):T;
fun next_N(s:stream[`T], n:int):sequence[T];
fun peek_next(:stream[`T], at_end:&():`S):T|S;
fun peek_next(s:stream[`T]):T;
fun as_collection(s:stream[`T]):sequence[T];
A mutable stream supports changing the value after current
position in the stream, and optionally advancing the position past
that value. A flush operation makes updates to stream values visible
externally, for those implementations of streams such as files that
have separate external views.
abstract class m_stream[T] isa stream[T];
fun set_peek_next(:m_stream[`T], :T):void;
fun set_next(s:m_stream[`T], x:T):void;
fun flush(:m_stream[`T]):void;
A removable_stream
supports the remove_next
operation, which
removes the next element from the stream.
abstract class removable_stream[T] isa stream[T],
removable_stream[`S >= T];
fun remove_next(:removable_stream[`T]):void;
An insertable_stream
allows an item (or a collection of items)
to be inserted immediately behind the current position of the
stream, i.e., the position in the stream is right after the inserted
value(s).
abstract class insertable_stream[T] isa stream[T];
fun insert(:insertable_stream[`T], :T):void;
fun insert_all(s:insertable_stream[`T], c:ordered_collection[T]):void;
An extensible_stream
allows an item (or a collection of items)
to be added to the end of the stream; the position of the stream is
moved to the end of the stream after the added items.
abstract class extensible_stream[T] isa stream[T];
A reversible_stream
allows backward motion through the
stream. It supports backward-looking functions analogous to the
forward-looking operations of the generic stream. Similarly,
m_reversible_stream
supports backwards-looking mutation operations.
abstract class reversible_stream[T] isa stream[T],
reversible_stream[`S >= T];
fun is_at_start(:reversible_stream[`T]):bool;
fun after_start(s:reversible_stream[`T]):bool;
fun backward(:reversible_stream[`T], at_start:&():void):void;
fun backward(s:reversible_stream[`T]):void;
fun prev(:reversible_stream[`T], at_start:&():`S):T|S;
fun prev(s:reversible_stream[`T]):T;
fun peek_prev(:reversible_stream[`T], at_start:&():`S):T|S;
fun peek_prev(s:reversible_stream[`T]):T;
abstract class m_reversible_stream[T] isa reversible_stream[T],
m_stream[T];
fun set_peek_prev(:m_reversible_stream[`T], :T):void;
fun set_prev(s:m_reversible_stream[`T], x:T):void;
A positionable_stream
supports querying and setting the position
in the stream explicitly. The length of the stream can be determined
also.
abstract class positionable_stream[T] isa reversible_stream[T],
positionable_stream[`S >= T];
fun position(:positionable_stream[`T]):int;
fun set_position(:positionable_stream[`T], :int, off_end:&():void):void;
fun set_position(s:positionable_stream[`T], p:int):void;
fun to_start(s:positionable_stream[`T]):void;
fun to_end(s:positionable_stream[`T]):void;
fun view_indexed(:positionable_stream[`T]):indexed[T];
abstract class m_positionable_stream[T] isa positionable_stream[T],
m_reversible_stream[T];
Next: stream_views ; view_stream
Up: Input/output
Previous: Input/output
Index
Cecil/Vortex Project