View Source Arrays.Implementations.ErlangArray (Arrays v2.1.1)
Wraps the Erlang :array
module.
These kinds of arrays use a 'functional tree' format, with a leaf size of 10 nodes wide (ref.).
Common operations like element access thus take O(log10(n)) time.
Note that when no custom default value is specified,
nil
will be used, rather than :array
's default of :undefined
.
Summary
Functions
Create an %ErlangArray{}
-struct from an :array
-record.
Implementation for FunLand.Mappable.map
.
A variant of reduce that accepts anything that is Combinable as second argument. This Combinable will determine what the empty value and the combining operation will be.
Implementation for FunLand.Reducible.reduce
.
Converts the reducible into a list, by building up a list from all elements, and in the end reversing it.
Turn an %ErlangArray{}-struct back into an :array
-record.
Functions
Create an %ErlangArray{}
-struct from an :array
-record.
iex> :array.new([]) |> ErlangArray.from_raw()
#Arrays.Implementations.ErlangArray<[]>
Implementation for FunLand.Mappable.map
.
Note that FunLand
is an optional dependency of Arrays
so you need to add it to your mix.exs
dependencies manually to use it.
A variant of reduce that accepts anything that is Combinable as second argument. This Combinable will determine what the empty value and the combining operation will be.
Pass in the combinable module name to start with empty
as accumulator,
or the combinable as struct to use that as starting accumulator.
This is an automatic function implementation, made possible because Arrays.Implementations.ErlangArray
implements the FunLand.Reducible
behaviour.
See FunLand.Reducible.reduce/2
for examples.
Implementation for FunLand.Reducible.reduce
.
Note that FunLand
is an optional dependency of Arrays
so you need to add it to your mix.exs
dependencies manually to use it.
Converts the reducible into a list, by building up a list from all elements, and in the end reversing it.
This is an automatic function implementation, made possible because Arrays.Implementations.ErlangArray
implements the FunLand.Reducible
behaviour.
Turn an %ErlangArray{}-struct back into an :array
-record.
iex> Arrays.new([1, 2, 3], implementation: Arrays.Implementations.ErlangArray) |> ErlangArray.to_raw()
{:array, 3, 10, nil, {1, 2, 3, nil, nil, nil, nil, nil, nil, nil}}