array

MODULE

MODULE SUMMARY

DESCRIPTION

Functional, extendible arrays. Arrays can have fixed size, or
can grow automatically as needed. A default value is used for entries
that have not been explicitly set.

Arrays uses zero based indexing. This is a deliberate design
choice and differs from other erlang datastructures, e.g. tuples.

Unless specified by the user when the array is created, the default
value is the atom undefined. There is no difference between an
unset entry and an entry which has been explicitly set to the same
value as the default one (cf. reset/2). If you need to
differentiate between unset and set entries, you must make sure that
the default value cannot be confused with the values of set entries.

The array never shrinks automatically; if an index I has been used
successfully to set an entry, all indices in the range [0,I] will
stay accessible unless the array size is explicitly changed by
calling resize/2.

Fold the elements of the array using the given function and
initial accumulator value. The elements are visited in order from the
lowest index to the highest. If Function is not a function, the
call fails with reason badarg.

Fold the elements of the array right-to-left using the given
function and initial accumulator value. The elements are visited in
order from the highest index to the lowest. If Function is not a
function, the call fails with reason badarg.

Convert an ordered list of pairs {Index, Value} to a
corresponding extendible array. Default is used as the value for
uninitialized entries of the array. If List is not a proper,
ordered list of pairs whose first elements are nonnegative
integers, the call fails with reason badarg.

Create a new array according to the given size and options. If
Size is not a nonnegative integer, the call fails with reason
badarg. By default, the array has fixed size. Note that any size
specifications in Options will override the Size parameter.

If Options is a list, this is simply equivalent to new([{size,
Size} | Options], otherwise it is equivalent to new([{size, Size} |
[Options]]. However, using this function directly is more efficient.

Reset entry I to the default value for the array. This is
equivalent to set(I, default(Array), Array), and hence may cause
the array to grow in size, but will not shrink it. Shrinking can be
done explicitly by calling resize/2.

If I is not a nonnegative integer, or if the array has fixed size
and I is larger than the maximum index, the call fails with reason
badarg; cf. set/3

Fold the elements of the array using the given function and
initial accumulator value, skipping default-valued entries. The
elements are visited in order from the lowest index to the highest.
If Function is not a function, the call fails with reason badarg.

Fold the elements of the array right-to-left using the given
function and initial accumulator value, skipping default-valued
entries. The elements are visited in order from the highest index to
the lowest. If Function is not a function, the call fails with
reason badarg.

Map the given function onto each element of the array, skipping
default-valued entries. The elements are visited in order from the
lowest index to the highest. If Function is not a function, the
call fails with reason badarg.