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.
129
130       is_subset(Ordset1, Ordset2) -> boolean()
131
132              Types:
133
134                 Ordset1 = Ordset2 = ordset(term())
135
136              Returns  true  when every element of Ordset1 is also a member of
137              Ordset2, otherwise false.
138
139       new() -> []
140
141              Returns a new empty ordered set.
142
143       size(Ordset) -> integer() >= 0
144
145              Types:
146
147                 Ordset = ordset(term())
148
149              Returns the number of elements in Ordset.
150
151       subtract(Ordset1, Ordset2) -> Ordset3
152
153              Types:
154
155                 Ordset1 = Ordset2 = Ordset3 = ordset(term())
156
157              Returns only the elements of Ordset1 that are not also  elements
158              of Ordset2.
159
160       to_list(Ordset) -> List
161
162              Types:
163
164                 Ordset = ordset(T)
165                 List = [T]
166
167              Returns the elements of Ordset as a list.
168
169       union(OrdsetList) -> Ordset
170
171              Types:
172
173                 OrdsetList = [ordset(T)]
174                 Ordset = ordset(T)
175
176              Returns the merged (union) set of the list of sets.
177
178       union(Ordset1, Ordset2) -> Ordset3
179
180              Types:
181
182                 Ordset1 = ordset(T1)
183                 Ordset2 = ordset(T2)
184                 Ordset3 = ordset(T1 | T2)
185
186              Returns the merged (union) set of Ordset1 and Ordset2.
187

SEE ALSO

189       gb_sets(3), sets(3)
190
191
192
193Ericsson AB                      stdlib 3.16.1                      ordsets(3)
Impressum