Pipeline
in package
implements
IteratorAggregate
A pipeline represents an asynchronous set and provides operations which can be applied over the set.
Tags
Table of Contents
Interfaces
- IteratorAggregate
Properties
- $bufferSize : int
- $concurrency : positive-int
- $intermediateOperations : array<int, IntermediateOperation>
- $ordered : bool
- $source : ConcurrentIterator
- $used : bool
Methods
- __construct() : mixed
- __destruct() : mixed
- allMatch() : bool
- anyMatch() : bool
- buffer() : self
- concat() : Ts>
- Concatenates the given iterables into a single pipeline in sequential order.
- concurrent() : self
- count() : int
- delay() : T>
- Delays each item by $delay seconds.
- dispose() : void
- filter() : T>
- Filters values.
- flatMap() : R>
- Maps values, flattening one level.
- forEach() : void
- Invokes the given callback for each value emitted on the pipeline.
- fromIterable() : Ts>
- Creates a pipeline from the given iterable or closure returning an iterable.
- generate() : Ts>
- Creates an infinite pipeline from the given closure invoking it repeatedly for each value.
- getIterator() : ConcurrentIterator<string|int, T>
- map() : R>
- Maps values.
- max() : T|R
- merge() : Ts>
- Merges the given iterables into a single pipeline. The returned pipeline emits a value anytime one of the merged iterables produces a value.
- min() : T|R
- noneMatch() : bool
- ordered() : self
- reduce() : R
- sequential() : self
- skip() : T>
- Skip the first N items of the pipeline.
- skipWhile() : T>
- Skips values on the pipeline until {@code $predicate} returns {@code false}.
- sorted() : R>
- Sorts values, requires buffering all values.
- take() : T>
- Take only the first N items of the pipeline.
- takeWhile() : T>
- Takes values on the pipeline until {@code $predicate} returns {@code false}.
- tap() : T>
- Invokes the given function each time a value is streamed through the pipeline to perform side effects.
- toArray() : array<int, T>
- Collects all items into an array.
- unordered() : self
- mapToConcurrentIterators() : array<string|int, mixed>
Properties
$bufferSize
private
int
$bufferSize
= 0
non-negative-int
$concurrency
private
positive-int
$concurrency
= 1
$intermediateOperations
private
array<int, IntermediateOperation>
$intermediateOperations
= []
$ordered
private
bool
$ordered
= true
$source read-only
private
ConcurrentIterator
$source
$used
private
bool
$used
= false
Methods
__construct()
public
__construct(ConcurrentIterator<string|int, T> $source) : mixed
Parameters
- $source : ConcurrentIterator<string|int, T>
__destruct()
public
__destruct() : mixed
allMatch()
public
allMatch(callable(T): bool $predicate) : bool
Parameters
- $predicate : callable(T): bool
Return values
boolanyMatch()
public
anyMatch(callable(T): bool $predicate) : bool
Parameters
- $predicate : callable(T): bool
Return values
boolbuffer()
public
buffer(int $bufferSize) : self
Parameters
- $bufferSize : int
Return values
selfconcat()
Concatenates the given iterables into a single pipeline in sequential order.
public
static concat(array<string|int, iterable<string|int, Ts>> $pipelines) : Ts>
The prior pipeline must complete before values are taken from any subsequent pipelines.
Parameters
- $pipelines : array<string|int, iterable<string|int, Ts>>
Tags
Return values
Ts>concurrent()
public
concurrent(int $concurrency) : self
Parameters
- $concurrency : int
Return values
selfcount()
public
count() : int
Return values
intdelay()
Delays each item by $delay seconds.
public
delay(float $delay) : T>
Parameters
- $delay : float
Return values
T>dispose()
public
dispose() : void
filter()
Filters values.
public
filter(callable(T): bool $filter) : T>
Parameters
- $filter : callable(T): bool
-
Keep value if $filter returns true.
Return values
T>flatMap()
Maps values, flattening one level.
public
flatMap(callable(T, int): iterable<string|int, R> $flatMap) : R>
Parameters
- $flatMap : callable(T, int): iterable<string|int, R>
Tags
Return values
R>forEach()
Invokes the given callback for each value emitted on the pipeline.
public
forEach(callable(T): void $forEach) : void
Parameters
- $forEach : callable(T): void
fromIterable()
Creates a pipeline from the given iterable or closure returning an iterable.
public
static fromIterable(callable(): iterable<string|int, Ts>|iterable<string|int, Ts> $iterable) : Ts>
Parameters
- $iterable : callable(): iterable<string|int, Ts>|iterable<string|int, Ts>
Tags
Return values
Ts>generate()
Creates an infinite pipeline from the given closure invoking it repeatedly for each value.
public
static generate(callable(Cancellation): Ts $supplier) : Ts>
Parameters
- $supplier : callable(Cancellation): Ts
-
Elements to emit.
Tags
Return values
Ts>getIterator()
public
getIterator() : ConcurrentIterator<string|int, T>
Return values
ConcurrentIterator<string|int, T>map()
Maps values.
public
map(callable(T): R $map) : R>
Parameters
- $map : callable(T): R
Tags
Return values
R>max()
public
max([null|callable(T, T): int $compare = null ][, R $default = null ]) : T|R
Parameters
- $compare : null|callable(T, T): int = null
- $default : R = null
Tags
Return values
T|Rmerge()
Merges the given iterables into a single pipeline. The returned pipeline emits a value anytime one of the merged iterables produces a value.
public
static merge(array<string|int, iterable<string|int, Ts>> $pipelines) : Ts>
Parameters
- $pipelines : array<string|int, iterable<string|int, Ts>>
-
f
Tags
Return values
Ts>min()
public
min([null|callable(T, T): int $compare = null ][, R $default = null ]) : T|R
Parameters
- $compare : null|callable(T, T): int = null
- $default : R = null
Tags
Return values
T|RnoneMatch()
public
noneMatch(callable(T): bool $predicate) : bool
Parameters
- $predicate : callable(T): bool
Return values
boolordered()
public
ordered() : self
Return values
selfreduce()
public
reduce(callable(R, T): R $accumulator[, R $initial = null ]) : R
Parameters
- $accumulator : callable(R, T): R
- $initial : R = null
Tags
Return values
Rsequential()
public
sequential() : self
Return values
selfskip()
Skip the first N items of the pipeline.
public
skip(int $count) : T>
Parameters
- $count : int
Return values
T>skipWhile()
Skips values on the pipeline until {@code $predicate} returns {@code false}.
public
skipWhile(callable(T): bool $predicate) : T>
All values are emitted afterwards without invoking $predicate.
Parameters
- $predicate : callable(T): bool
Return values
T>sorted()
Sorts values, requires buffering all values.
public
sorted([null|callable(T, T): int $compare = null ]) : R>
Parameters
- $compare : null|callable(T, T): int = null
Tags
Return values
R>take()
Take only the first N items of the pipeline.
public
take(int $count) : T>
Parameters
- $count : int
Return values
T>takeWhile()
Takes values on the pipeline until {@code $predicate} returns {@code false}.
public
takeWhile(callable(T): bool $predicate) : T>
Parameters
- $predicate : callable(T): bool
Return values
T>tap()
Invokes the given function each time a value is streamed through the pipeline to perform side effects.
public
tap(callable(T): void $tap) : T>
Parameters
- $tap : callable(T): void
Return values
T>toArray()
Collects all items into an array.
public
toArray() : array<int, T>
Return values
array<int, T>unordered()
public
unordered() : self
Return values
selfmapToConcurrentIterators()
private
static mapToConcurrentIterators(array<string|int, mixed> $iterables) : array<string|int, mixed>
Parameters
- $iterables : array<string|int, mixed>