# ordsets

## 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 the same interface as the
`sets(3)`

module
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 (`==`

).

#### Functions

### add_element(Element, Ordset1) -> Ordset2

Returns a new ordered set formed from

with

inserted.

### del_element(Element, Ordset1) -> Ordset2

`Element = term()`

`Ordset1 = Ordset2 = ordset(T)`

Returns

, but with

removed.

### filter(Pred, Ordset1) -> Ordset2

`Pred = fun((Element :: T) -> boolean())`

`Ordset1 = Ordset2 = ordset(T)`

Filters elements in

with boolean function

.

### fold(Function, Acc0, Ordset) -> Acc1

`Function =`

fun((Element :: T, AccIn :: term()) -> AccOut :: term())`Ordset = ordset(T)`

`Acc0 = Acc1 = term()`

Folds

over every element in

and returns the final value of the
accumulator.

### from_list(List) -> Ordset

`List = [T]`

`Ordset = ordset(T)`

Returns an ordered set of the elements in

.

### intersection(OrdsetList) -> Ordset

Returns the intersection of the non-empty list of sets.

### intersection(Ordset1, Ordset2) -> Ordset3

`Ordset1 = Ordset2 = Ordset3 = ordset(term())`

Returns the intersection of

and

.

### is_disjoint(Ordset1, Ordset2) -> boolean()

`Ordset1 = Ordset2 = ordset(term())`

Returns `true`

if

and

are disjoint (have no elements in common),
otherwise `false`

.

### is_element(Element, Ordset) -> boolean()

`Element = term()`

`Ordset = ordset(term())`

Returns `true`

if

is an element of

, otherwise `false`

.

### is_set(Ordset) -> boolean()

`Ordset = term()`

Returns `true`

if

is an ordered set
of elements, otherwise `false`

.

### is_subset(Ordset1, Ordset2) -> boolean()

`Ordset1 = Ordset2 = ordset(term())`

Returns `true`

when every element of

is also a member of

, otherwise
`false`

.

### new() -> []

Returns a new empty ordered set.

### subtract(Ordset1, Ordset2) -> Ordset3

`Ordset1 = Ordset2 = Ordset3 = ordset(term())`

Returns only the elements of

that are not
also elements of

.

### union(OrdsetList) -> Ordset

Returns the merged (union) set of the list of sets.