Provided by: erlang-manpages_16.b.3-dfsg-1ubuntu2_all

**NAME**

ordsets - Functions for Manipulating Sets as Ordered Lists

**DESCRIPTION**

Sets are collections of elements with no duplicate elements. Anordsetis 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 modulesetsbut with a defined representation. One difference is that whilesetsconsiders 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**

new()->[]Returns a new empty ordered set.is_set(Ordset)->boolean()Types: Ordset = term() ReturnstrueifOrdsetis an ordered set of elements, otherwisefalse.size(Ordset)->integer()>=0Types: Ordset =ordset(term()) Returns the number of elements inOrdset.to_list(Ordset)->ListTypes: Ordset =ordset(T) List = [T] Returns the elements ofOrdsetas a list.from_list(List)->OrdsetTypes: List = [T] Ordset =ordset(T) Returns an ordered set of the elements inList.is_element(Element,Ordset)->boolean()Types: Element = term() Ordset =ordset(term()) ReturnstrueifElementis an element ofOrdset, otherwisefalse.add_element(Element,Ordset1)->Ordset2Types: Element = E Ordset1 =ordset(T) Ordset2 =ordset(T | E) Returns a new ordered set formed fromOrdset1withElementinserted.del_element(Element,Ordset1)->Ordset2Types: Element = term() Ordset1 = Ordset2 =ordset(T) ReturnsOrdset1, but withElementremoved.union(Ordset1,Ordset2)->Ordset3Types: Ordset1 =ordset(T1) Ordset2 =ordset(T2) Ordset3 =ordset(T1 | T2) Returns the merged (union) set ofOrdset1andOrdset2.union(OrdsetList)->OrdsetTypes: OrdsetList = [ordset(T)] Ordset =ordset(T) Returns the merged (union) set of the list of sets.intersection(Ordset1,Ordset2)->Ordset3Types: Ordset1 = Ordset2 = Ordset3 =ordset(term()) Returns the intersection ofOrdset1andOrdset2.intersection(OrdsetList)->OrdsetTypes: OrdsetList = [ordset(term()), ...] Ordset =ordset(term()) Returns the intersection of the non-empty list of sets.is_disjoint(Ordset1,Ordset2)->boolean()Types: Ordset1 = Ordset2 =ordset(term()) ReturnstrueifOrdset1andOrdset2are disjoint (have no elements in common), andfalseotherwise.subtract(Ordset1,Ordset2)->Ordset3Types: Ordset1 = Ordset2 = Ordset3 =ordset(term()) Returns only the elements ofOrdset1which are not also elements ofOrdset2.is_subset(Ordset1,Ordset2)->boolean()Types: Ordset1 = Ordset2 =ordset(term()) Returnstruewhen every element ofOrdset1is also a member ofOrdset2, otherwisefalse.fold(Function,Acc0,Ordset)->Acc1Types: Function = fun((Element :: T, AccIn :: term()) -> AccOut :: term()) Ordset =ordset(T) Acc0 = Acc1 = term() FoldFunctionover every element inOrdsetreturning the final value of the accumulator.filter(Pred,Ordset1)->Ordset2Types: Pred = fun((Element :: T) -> boolean()) Ordset1 = Ordset2 =ordset(T) Filter elements inOrdset1with boolean functionPred.

**SEE** **ALSO**

gb_sets(3erl),sets(3erl)