Help-me

Robert Virding <>
Tue Apr 3 11:16:51 CEST 2001


Ulf Wiger <> writes:
>On Tue, 3 Apr 2001, Raimo Niskanen wrote:
>
>For small arrays, you can use a tuple:
>
>array(Size) -> erlang:make_tuple(Size).
>
>read(Pos, Array) -> element(Pos, Array).
>
>write(Pos, Array, Value) -> setelement(Pos, Array, Value).
>
>
>But performance for write/3 will not be that great for bigger arrays.
>
>On http://www.erlang.org, under "User Contributions", you can find
>something called dynarray. It's a dynamically sized array-like
>structure that works like the small example above.
>
>Or, use ETS or process dictionary as Raimo suggests.

The standard dict module in stdlib will do the same thing as dynarray
and it has the added benefit that not only does it expand on demand it
will also compact when it can.

	Robert



More information about the erlang-questions mailing list