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
21       See the Compatibility Section in the sets(3) module for  more  informa‐
22       tion  about  the compatibility of the different implementations of sets
23       in the Standard Library.
24

DATA TYPES

26       ordset(T) = [T]
27
28              As returned by new/0.
29

EXPORTS

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

SEE ALSO

194       gb_sets(3), sets(3)
195
196
197
198Ericsson AB                      stdlib 5.1.1                       ordsets(3)
Impressum