Is there a module that implements an efficient array type in Erlang?
Posted
by
dsmith
on Stack Overflow
See other posts from Stack Overflow
or by dsmith
Published on 2012-09-12T19:35:33Z
Indexed on
2012/09/12
21:38 UTC
Read the original article
Hit count: 238
data-structures
|erlang
I have been looking for an array type with the following characteristics in Erlang.
append(vector(), term()) O(1)
nth(Idx, vector()) O(1)
set(Idx, vector(), term()) O(1)
insert(Idx, vector(), term()) O(N)
remove(Idx, vector()) O(N)
I normally use a tuple for this purpose, but the performance characteristics are not what I would want for large N. My testing shows the following performance characteristics...
erlang:append_element/2 O(N).
erlang:setelement/3 O(N).
I have started on a module based on the clojure.lang.PersistentVector implementation, but if it's already been done I won't reinvent the wheel.
© Stack Overflow or respective owner