ordsets
(stdlib)Functions for Manipulating Sets as Ordered Lists
Sets are collections of elements with no duplicate elements.
An ordset
is a representation of a set, where an ordered
list is used to store the elements of the set. An ordered list
is more efficient than an unordered list.
This module provides exactly the same interface as the module
sets
but with a defined representation. One difference is
that while sets
considers two elements as different if they
do not match (=:=
), this module considers two elements as
different if and only if they do not compare equal (==
).
As returned by new/0.
Functions
new() -> []
Returns a new empty ordered set.
is_set(Ordset) -> boolean()
Returns true
if
is an ordered set of
elements, otherwise false
.
size(Ordset) -> integer() >= 0
Returns the number of elements in
.
to_list(Ordset) -> List
Returns the elements of
as a list.
from_list(List) -> Ordset
Returns an ordered set of the elements in
.
is_element(Element, Ordset) -> boolean()
Returns true
if
is an element of
, otherwise false
.
add_element(Element, Ordset1) -> Ordset2
Returns a new ordered set formed from
with
inserted.
del_element(Element, Ordset1) -> Ordset2
Returns
, but with
removed.
union(Ordset1, Ordset2) -> Ordset3
Returns the merged (union) set of
and
.
union(OrdsetList) -> Ordset
Returns the merged (union) set of the list of sets.
intersection(Ordset1, Ordset2) -> Ordset3
Returns the intersection of
and
.
intersection(OrdsetList) -> Ordset
Returns the intersection of the non-empty list of sets.
is_disjoint(Ordset1, Ordset2) -> boolean()
Returns true
if
and
are disjoint (have no elements in common),
and false
otherwise.
subtract(Ordset1, Ordset2) -> Ordset3
Returns only the elements of
which are not
also elements of
.
is_subset(Ordset1, Ordset2) -> boolean()
Returns true
when every element of
is
also a member of
, otherwise false
.
fold(Function, Acc0, Ordset) -> Acc1
Fold
over every element in
returning the final value of the accumulator.
filter(Pred, Ordset1) -> Ordset2
Filter elements in
with boolean function
.