steady_vector
steady_vector is a persistent vector for Erlang and Elixir: an array-like
collection of values optimized for tail growth and shrinkage. It's heavily based
on Dmitry Kakurin's
PersistentVector implementation
for Elixir and, other than some idiomatic changes and a few new functions, its
interface is conceptually very similar.
steady_vector optimizes the following operations:
- getting the element count
- looking up an element by its 0-based index
- updating an element by its 0-based index
- appending a new element to the end
- removing the last element
- enumeration
- mapping
- folding (left and right)
Getting the element count is O(1); most other operations are O(log32(N)).
It is implemented as a tree with 32-way branching at each level and uses
structural sharing for updates. All ideas are borrowed directly from
PersistentVector, which in turn borrowed them from
Clojure.
Installation
Erlang
Add steady_vector to your list of dependencies in rebar.config:
{deps, [
{steady_vector, "~> 1.1"}
]}.
And then run rebar3 compile.
Elixir
Add steady_vector to your list of dependencies in mix.exs:
def deps do
[
{:steady_vector, "~> 1.1"}
]
end
And then run mix deps.get.
Documentation
The API reference is available on HexDocs.
Requirements
steady_vector is tested against Erlang/OTP 24 to 29. The supported build tool
is rebar3.
License
steady_vector is licensed under the MIT license. See the LICENSE
file for details.