1ordsets(3)                 Erlang Module Definition                 ordsets(3)
2
3
4

NAME

6       ordsets - Functions for manipulating sets as ordered lists.
7
8

DESCRIPTION

10       Sets  are collections of elements with no duplicate elements. An ordset
11       is a representation of a set, where an ordered list is  used  to  store
12       the  elements of the set. An ordered list is more efficient than an un‐
13       ordered list. Elements are ordered according to the Erlang term order.
14
15       This module provides the same interface as the sets(3) module but  with
16       a  defined  representation. One difference is that while sets considers
17       two elements as different if they do not match (=:=), this module  con‐
18       siders  two  elements  as  different if and only if they do not compare
19       equal (==).
20

DATA TYPES

22       ordset(T) = [T]
23
24              As returned by new/0.
25

EXPORTS

27       add_element(Element, Ordset1) -> Ordset2
28
29              Types:
30
31                 Element = E
32                 Ordset1 = ordset(T)
33                 Ordset2 = ordset(T | E)
34
35              Returns a new ordered set formed from Ordset1 with  Element  in‐
36              serted.
37
38       del_element(Element, Ordset1) -> Ordset2
39
40              Types:
41
42                 Element = term()
43                 Ordset1 = Ordset2 = ordset(T)
44
45              Returns Ordset1, but with Element removed.
46
47       filter(Pred, Ordset1) -> Ordset2
48
49              Types:
50
51                 Pred = fun((Element :: T) -> boolean())
52                 Ordset1 = Ordset2 = ordset(T)
53
54              Filters elements in Ordset1 with boolean function Pred.
55
56       fold(Function, Acc0, Ordset) -> Acc1
57
58              Types:
59
60                 Function =
61                     fun((Element :: T, AccIn :: term()) -> AccOut :: term())
62                 Ordset = ordset(T)
63                 Acc0 = Acc1 = term()
64
65              Folds  Function over every element in Ordset and returns the fi‐
66              nal value of the accumulator.
67
68       from_list(List) -> Ordset
69
70              Types:
71
72                 List = [T]
73                 Ordset = ordset(T)
74
75              Returns an ordered set of the elements in List.
76
77       intersection(OrdsetList) -> Ordset
78
79              Types:
80
81                 OrdsetList = [ordset(term()), ...]
82                 Ordset = ordset(term())
83
84              Returns the intersection of the non-empty list of sets.
85
86       intersection(Ordset1, Ordset2) -> Ordset3
87
88              Types:
89
90                 Ordset1 = Ordset2 = Ordset3 = ordset(term())
91
92              Returns the intersection of Ordset1 and Ordset2.
93
94       is_disjoint(Ordset1, Ordset2) -> boolean()
95
96              Types:
97
98                 Ordset1 = Ordset2 = ordset(term())
99
100              Returns true if Ordset1 and Ordset2 are disjoint (have  no  ele‐
101              ments in common), otherwise false.
102
103       is_element(Element, Ordset) -> boolean()
104
105              Types:
106
107                 Element = term()
108                 Ordset = ordset(term())
109
110              Returns  true  if  Element  is  an  element of Ordset, otherwise
111              false.
112
113       is_empty(Ordset) -> boolean()
114
115              Types:
116
117                 Ordset = ordset(term())
118
119              Returns true if Ordset is an empty set, otherwise false.
120
121       is_set(Ordset) -> boolean()
122
123              Types:
124
125                 Ordset = term()
126
127              Returns true if Ordset is an ordered set of elements,  otherwise
128              false. This function will return true for any ordered list, even
129              when not constructed by the functions in this module.
130
131       is_subset(Ordset1, Ordset2) -> boolean()
132
133              Types:
134
135                 Ordset1 = Ordset2 = ordset(term())
136
137              Returns true when every element of Ordset1 is also a  member  of
138              Ordset2, otherwise false.
139
140       new() -> []
141
142              Returns a new empty ordered set.
143
144       size(Ordset) -> integer() >= 0
145
146              Types:
147
148                 Ordset = ordset(term())
149
150              Returns the number of elements in Ordset.
151
152       subtract(Ordset1, Ordset2) -> Ordset3
153
154              Types:
155
156                 Ordset1 = Ordset2 = Ordset3 = ordset(term())
157
158              Returns  only the elements of Ordset1 that are not also elements
159              of Ordset2.
160
161       to_list(Ordset) -> List
162
163              Types:
164
165                 Ordset = ordset(T)
166                 List = [T]
167
168              Returns the elements of Ordset as a list.
169
170       union(OrdsetList) -> Ordset
171
172              Types:
173
174                 OrdsetList = [ordset(T)]
175                 Ordset = ordset(T)
176
177              Returns the merged (union) set of the list of sets.
178
179       union(Ordset1, Ordset2) -> Ordset3
180
181              Types:
182
183                 Ordset1 = ordset(T1)
184                 Ordset2 = ordset(T2)
185                 Ordset3 = ordset(T1 | T2)
186
187              Returns the merged (union) set of Ordset1 and Ordset2.
188

SEE ALSO

190       gb_sets(3), sets(3)
191
192
193
194Ericsson AB                       stdlib 4.2                        ordsets(3)
Impressum