View Source shards_enum (shards v1.1.1)
Summary
Functions
Returns a list where each element is the result of invoking Fun
on each corresponding element of Enumerable
.
Equivalent to pmap(Fun, infinity, Enumerable).
Similar to
shards_enum:map/2
but it runs in parallel.Invokes Fun
for each element in the Enumerable
with the accumulator.
Reduces enumerable until Fun
returns {halt, AccOut}
.
Functions
-spec map(Fun, Enumerable) -> [Result] when Fun :: fun((Elem) -> Result), Elem :: term(), Result :: term(), Enumerable :: [term()] | map() | non_neg_integer().
Returns a list where each element is the result of invoking Fun
on each corresponding element of Enumerable
.
Equivalent to pmap(Fun, infinity, Enumerable).
-spec pmap(Fun, Timeout, Enumerable) -> [Result] when Fun :: fun((Elem) -> Result), Elem :: term(), Timeout :: timeout(), Result :: term(), Enumerable :: [term()] | map() | non_neg_integer().
shards_enum:map/2
but it runs in parallel.
-spec reduce(Fun, Acc0, Enumerable) -> Acc1 when Fun :: fun((Elem, AccIn) -> AccOut), Elem :: term(), AccIn :: term(), AccOut :: term(), Acc0 :: term(), Acc1 :: term(), Enumerable :: [term()] | map() | non_neg_integer().
Invokes Fun
for each element in the Enumerable
with the accumulator.
Acc0
. The function is invoked for each element in the enumerable with the accumulator. The result returned by the function is used as the accumulator for the next iteration. The function returns the last accumulator.
-spec reduce_while(Fun, Acc0, Enumerable) -> Acc1 when Fun :: fun((Elem, AccIn) -> FunRes), FunRes :: {cont | halt, AccOut}, Elem :: term(), AccIn :: term(), AccOut :: term(), Acc0 :: term(), Acc1 :: term(), Enumerable :: [term()] | map() | non_neg_integer().
Reduces enumerable until Fun
returns {halt, AccOut}
.
The return value for Fun
is expected to be
{cont, AccOut}
to continue the reduction withAccOut
as the new accumulator or{halt, AccOut}
to halt the reduction
{halt, AccOut}
the reduction is halted and the function returns AccOut
. Otherwise, if the enumerable is exhausted, the function returns the accumulator of the last {cont, AccOut}
.