Seq


Object Hierarchy:

Gpseq.Seq Gpseq.Seq Gpseq.Seq GLib.Object GLib.Object GLib.Object->Gpseq.Seq

Description:


public class Seq<G> : Object

A sequence of elements, supporting sequential and parallel operations.

Seq pipelines

There are two kinds of operations in seq; intermediate and terminal operations. A seq pipeline consists of zero or more intermediate operations and a terminal operation.

Intermediate operations

Intermediate operations are always lazy. It means that traversal of the source does not begin until a terminal operation is executed. They return a new seq that will perform the operation, and the operation will be performed just before a terminal operation is executed. The previous seq, that has called the intermediate operation method, of the new one is closed and can no longer be used.

Intermediate operations are further divided into stateless and stateful operations. Stateless operations retain no state from previously seen element when processing a new element. Therefore, each element can be processed independently on other elements. Stateful operations may incorporate state from previously seen elements when processing new elements, and may need to process the entire input before producing a result. Consequently, seq pipelines containing stateful intermediate operations may require multiple passes or may need to buffer significant data. On the contrary, seq pipelines containing only stateless intermediate (and terminal) operations can be processed in a single pass.

Terminal operations

Terminal operations may traverse the source to produce a result or a side-effect. Almost all of terminal operations are eager. They complete their traversal of the input and processing of the pipeline before the future completed. The only exceptions are Seq.iterator and Seq.spliterator. They are provided for client-controlled traversals. After a terminal operation is performed, the seq is closed and can no longer be used.

Short-circuiting

Some operations are regarded as short-circuiting operations. A short-circuiting intermediate operation may produce a finite seq as a result when infinite input given. A short-circuiting terminal operation may terminate in finite time when infinite input given. For processing a seq of infinite source to terminate normally in finite time, it is necessary that the pipeline contains a short-circuiting operation.

Parallelism

When the terminal operation is started, the seq pipeline is executed sequentially or in parallel depending on the mode of the seq on which it is invoked. The mode is sequential in an initial seq, and can be changed by Seq.sequential and Seq.parallel intermediate operations.

All operations respect encounter order in sequential execution. In parallel execution, however, all stateful intermediate and terminal operations may not respect the encounter order, except for operations identified as explicitly ordered such as Seq.find_first.

Non-interference

If a data source, such as list, is used to create a seq, the data source must not be interfered until the execution of the seq pipeline is completed. It means ensuring that the data source is not modified until the execution of the seq pipeline is completed. Except for the non- eager operations iterator() and spliterator(), execution is performed when the terminal operation is invoked. In case of the non-eager operations, the data source must not be modified while the iterator/spliterator is used.

Stateless

The result of seq pipeline may be nondeterministic or incorrect if the behaviors to the seq operations are stateful -- its result depends on any state that might change during the execution of the seq pipeline.

Associativity

An associative operator or function '~' follows: (a ~ b) ~ c == a ~ (b ~ c)

Numeric addition, numeric multiplication, min, max, and string concatenation are examples of associative operations.

Notes

With nullable primitive types, operations using GLib.CompareDataFunc function, such as order_by(), produce an undesirable result if the compare function is not specified. You should provide specified compare function to get a proper result.

Some operation might not work properly with unowned types. The best approach is never to use unowned types for seq.

If an operation method is tried after the seq has been closed, the try is (assertion) failed.

A result future of a sequential pipeline is already completed when returned from the terminal operation method, and therefore you do not have to wait the future for getting the value.


Namespace: Gpseq
Package: gpseq-1.0

Content:

Properties:

Static methods:

Creation methods:

Methods:

Inherited Members: