## table of contents

- bookworm 1:25.2.3+dfsg-1
- testing 1:25.2.3+dfsg-1
- unstable 1:25.2.3+dfsg-1
- experimental 1:26.0.2+dfsg-1

ordsets(3erl) | Erlang Module Definition | ordsets(3erl) |

# NAME¶

ordsets - Functions for manipulating sets as ordered lists.

# DESCRIPTION¶

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. Elements are ordered according to the *Erlang term
order*.

This module provides the same interface as the *sets(3erl)*
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 (*==*).

# DATA TYPES¶

ordset(T)= [T]

As returned by *new/0*.

# EXPORTS¶

add_element(Element, Ordset1) -> Ordset2

Types:

Ordset1 = ordset(T)

Ordset2 = ordset(T | E)

Returns a new ordered set formed from *Ordset1* with
*Element* inserted.

del_element(Element, Ordset1) -> Ordset2

Types:

Ordset1 = Ordset2 = ordset(T)

Returns *Ordset1*, but with *Element* removed.

filter(Pred, Ordset1) -> Ordset2

Types:

Ordset1 = Ordset2 = ordset(T)

Filters elements in *Ordset1* with boolean function
*Pred*.

fold(Function, Acc0, Ordset) -> Acc1

Types:

fun((Element :: T, AccIn :: term()) -> AccOut :: term())

Ordset = ordset(T)

Acc0 = Acc1 = term()

Folds *Function* over every element in *Ordset* and
returns the final value of the accumulator.

from_list(List) -> Ordset

Types:

Ordset = ordset(T)

Returns an ordered set of the elements in *List*.

intersection(OrdsetList) -> Ordset

Types:

Ordset = ordset(term())

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

intersection(Ordset1, Ordset2) -> Ordset3

Types:

Returns the intersection of *Ordset1* and *Ordset2*.

is_disjoint(Ordset1, Ordset2) -> boolean()

Types:

Returns *true* if *Ordset1* and *Ordset2* are
disjoint (have no elements in common), otherwise *false*.

is_element(Element, Ordset) -> boolean()

Types:

Ordset = ordset(term())

Returns *true* if *Element* is an element of
*Ordset*, otherwise *false*.

is_empty(Ordset) -> boolean()

Types:

Returns *true* if *Ordset* is an empty set, otherwise
*false*.

is_set(Ordset) -> boolean()

Types:

Returns *true* if *Ordset* is an ordered set of
elements, otherwise *false*.

is_subset(Ordset1, Ordset2) -> boolean()

Types:

Returns *true* when every element of *Ordset1* is also a
member of *Ordset2*, otherwise *false*.

new() -> []

Returns a new empty ordered set.

size(Ordset) -> integer() >= 0

Types:

Returns the number of elements in *Ordset*.

subtract(Ordset1, Ordset2) -> Ordset3

Types:

Returns only the elements of *Ordset1* that are not also
elements of *Ordset2*.

to_list(Ordset) -> List

Types:

List = [T]

Returns the elements of *Ordset* as a list.

union(OrdsetList) -> Ordset

Types:

Ordset = ordset(T)

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

union(Ordset1, Ordset2) -> Ordset3

Types:

Ordset2 = ordset(T2)

Ordset3 = ordset(T1 | T2)

Returns the merged (union) set of *Ordset1* and
*Ordset2*.

# SEE ALSO¶

*gb_sets(3erl)*, *sets(3erl)*

stdlib 3.17.2 | Ericsson AB |