.TH ordsets 3erl "stdlib 3.2" "Ericsson AB" "Erlang Module Definition" .SH NAME ordsets \- Functions for manipulating sets as ordered lists. .SH DESCRIPTION .LP Sets are collections of elements with no duplicate elements\&. An \fIordset\fR\& 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\&. .LP This module provides the same interface as the \fB\fIsets(3erl)\fR\&\fR\& module but with a defined representation\&. One difference is that while \fIsets\fR\& considers two elements as different if they do not match (\fI=:=\fR\&), this module considers two elements as different if and only if they do not compare equal (\fI==\fR\&)\&. .SH DATA TYPES .nf \fBordset(T)\fR\& = [T] .br .fi .RS .LP As returned by \fB\fInew/0\fR\&\fR\&\&. .RE .SH EXPORTS .LP .nf .B add_element(Element, Ordset1) -> Ordset2 .br .fi .br .RS .LP Types: .RS 3 Element = E .br Ordset1 = \fBordset\fR\&(T) .br Ordset2 = \fBordset\fR\&(T | E) .br .RE .RE .RS .LP Returns a new ordered set formed from \fIOrdset1\fR\& with \fIElement\fR\& inserted\&. .RE .LP .nf .B del_element(Element, Ordset1) -> Ordset2 .br .fi .br .RS .LP Types: .RS 3 Element = term() .br Ordset1 = Ordset2 = \fBordset\fR\&(T) .br .RE .RE .RS .LP Returns \fIOrdset1\fR\&, but with \fIElement\fR\& removed\&. .RE .LP .nf .B filter(Pred, Ordset1) -> Ordset2 .br .fi .br .RS .LP Types: .RS 3 Pred = fun((Element :: T) -> boolean()) .br Ordset1 = Ordset2 = \fBordset\fR\&(T) .br .RE .RE .RS .LP Filters elements in \fIOrdset1\fR\& with boolean function \fIPred\fR\&\&. .RE .LP .nf .B fold(Function, Acc0, Ordset) -> Acc1 .br .fi .br .RS .LP Types: .RS 3 Function = .br fun((Element :: T, AccIn :: term()) -> AccOut :: term()) .br Ordset = \fBordset\fR\&(T) .br Acc0 = Acc1 = term() .br .RE .RE .RS .LP Folds \fIFunction\fR\& over every element in \fIOrdset\fR\& and returns the final value of the accumulator\&. .RE .LP .nf .B from_list(List) -> Ordset .br .fi .br .RS .LP Types: .RS 3 List = [T] .br Ordset = \fBordset\fR\&(T) .br .RE .RE .RS .LP Returns an ordered set of the elements in \fIList\fR\&\&. .RE .LP .nf .B intersection(OrdsetList) -> Ordset .br .fi .br .RS .LP Types: .RS 3 OrdsetList = [\fBordset\fR\&(term()), \&.\&.\&.] .br Ordset = \fBordset\fR\&(term()) .br .RE .RE .RS .LP Returns the intersection of the non-empty list of sets\&. .RE .LP .nf .B intersection(Ordset1, Ordset2) -> Ordset3 .br .fi .br .RS .LP Types: .RS 3 Ordset1 = Ordset2 = Ordset3 = \fBordset\fR\&(term()) .br .RE .RE .RS .LP Returns the intersection of \fIOrdset1\fR\& and \fIOrdset2\fR\&\&. .RE .LP .nf .B is_disjoint(Ordset1, Ordset2) -> boolean() .br .fi .br .RS .LP Types: .RS 3 Ordset1 = Ordset2 = \fBordset\fR\&(term()) .br .RE .RE .RS .LP Returns \fItrue\fR\& if \fIOrdset1\fR\& and \fIOrdset2\fR\& are disjoint (have no elements in common), otherwise \fIfalse\fR\&\&. .RE .LP .nf .B is_element(Element, Ordset) -> boolean() .br .fi .br .RS .LP Types: .RS 3 Element = term() .br Ordset = \fBordset\fR\&(term()) .br .RE .RE .RS .LP Returns \fItrue\fR\& if \fIElement\fR\& is an element of \fIOrdset\fR\&, otherwise \fIfalse\fR\&\&. .RE .LP .nf .B is_set(Ordset) -> boolean() .br .fi .br .RS .LP Types: .RS 3 Ordset = term() .br .RE .RE .RS .LP Returns \fItrue\fR\& if \fIOrdset\fR\& is an ordered set of elements, otherwise \fIfalse\fR\&\&. .RE .LP .nf .B is_subset(Ordset1, Ordset2) -> boolean() .br .fi .br .RS .LP Types: .RS 3 Ordset1 = Ordset2 = \fBordset\fR\&(term()) .br .RE .RE .RS .LP Returns \fItrue\fR\& when every element of \fIOrdset1\fR\& is also a member of \fIOrdset2\fR\&, otherwise \fIfalse\fR\&\&. .RE .LP .nf .B new() -> [] .br .fi .br .RS .LP Returns a new empty ordered set\&. .RE .LP .nf .B size(Ordset) -> integer() >= 0 .br .fi .br .RS .LP Types: .RS 3 Ordset = \fBordset\fR\&(term()) .br .RE .RE .RS .LP Returns the number of elements in \fIOrdset\fR\&\&. .RE .LP .nf .B subtract(Ordset1, Ordset2) -> Ordset3 .br .fi .br .RS .LP Types: .RS 3 Ordset1 = Ordset2 = Ordset3 = \fBordset\fR\&(term()) .br .RE .RE .RS .LP Returns only the elements of \fIOrdset1\fR\& that are not also elements of \fIOrdset2\fR\&\&. .RE .LP .nf .B to_list(Ordset) -> List .br .fi .br .RS .LP Types: .RS 3 Ordset = \fBordset\fR\&(T) .br List = [T] .br .RE .RE .RS .LP Returns the elements of \fIOrdset\fR\& as a list\&. .RE .LP .nf .B union(OrdsetList) -> Ordset .br .fi .br .RS .LP Types: .RS 3 OrdsetList = [\fBordset\fR\&(T)] .br Ordset = \fBordset\fR\&(T) .br .RE .RE .RS .LP Returns the merged (union) set of the list of sets\&. .RE .LP .nf .B union(Ordset1, Ordset2) -> Ordset3 .br .fi .br .RS .LP Types: .RS 3 Ordset1 = \fBordset\fR\&(T1) .br Ordset2 = \fBordset\fR\&(T2) .br Ordset3 = \fBordset\fR\&(T1 | T2) .br .RE .RE .RS .LP Returns the merged (union) set of \fIOrdset1\fR\& and \fIOrdset2\fR\&\&. .RE .SH "SEE ALSO" .LP \fB\fIgb_sets(3erl)\fR\&\fR\&, \fB\fIsets(3erl)\fR\&\fR\&