1ordsets(3) Erlang Module Definition ordsets(3)
2
3
4
6 ordsets - Functions for manipulating sets as ordered lists.
7
8
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
13 unordered list. Elements are ordered according to the Erlang term
14 order.
15
16 This module provides the same interface as the sets(3) module but with
17 a defined representation. One difference is that while sets considers
18 two elements as different if they do not match (=:=), this module con‐
19 siders two elements as different if and only if they do not compare
20 equal (==).
21
23 ordset(T) = [T]
24
25 As returned by new/0.
26
28 add_element(Element, Ordset1) -> Ordset2
29
30 Types:
31
32 Element = E
33 Ordset1 = ordset(T)
34 Ordset2 = ordset(T | E)
35
36 Returns a new ordered set formed from Ordset1 with Element
37 inserted.
38
39 del_element(Element, Ordset1) -> Ordset2
40
41 Types:
42
43 Element = term()
44 Ordset1 = Ordset2 = ordset(T)
45
46 Returns Ordset1, but with Element removed.
47
48 filter(Pred, Ordset1) -> Ordset2
49
50 Types:
51
52 Pred = fun((Element :: T) -> boolean())
53 Ordset1 = Ordset2 = ordset(T)
54
55 Filters elements in Ordset1 with boolean function Pred.
56
57 fold(Function, Acc0, Ordset) -> Acc1
58
59 Types:
60
61 Function =
62 fun((Element :: T, AccIn :: term()) -> AccOut :: term())
63 Ordset = ordset(T)
64 Acc0 = Acc1 = term()
65
66 Folds Function over every element in Ordset and returns the
67 final value of the accumulator.
68
69 from_list(List) -> Ordset
70
71 Types:
72
73 List = [T]
74 Ordset = ordset(T)
75
76 Returns an ordered set of the elements in List.
77
78 intersection(OrdsetList) -> Ordset
79
80 Types:
81
82 OrdsetList = [ordset(term()), ...]
83 Ordset = ordset(term())
84
85 Returns the intersection of the non-empty list of sets.
86
87 intersection(Ordset1, Ordset2) -> Ordset3
88
89 Types:
90
91 Ordset1 = Ordset2 = Ordset3 = ordset(term())
92
93 Returns the intersection of Ordset1 and Ordset2.
94
95 is_disjoint(Ordset1, Ordset2) -> boolean()
96
97 Types:
98
99 Ordset1 = Ordset2 = ordset(term())
100
101 Returns true if Ordset1 and Ordset2 are disjoint (have no ele‐
102 ments in common), otherwise false.
103
104 is_element(Element, Ordset) -> boolean()
105
106 Types:
107
108 Element = term()
109 Ordset = ordset(term())
110
111 Returns true if Element is an element of Ordset, otherwise
112 false.
113
114 is_empty(Ordset) -> boolean()
115
116 Types:
117
118 Ordset = ordset(term())
119
120 Returns true if Ordset is an empty set, otherwise false.
121
122 is_set(Ordset) -> boolean()
123
124 Types:
125
126 Ordset = term()
127
128 Returns true if Ordset is an ordered set of elements, otherwise
129 false.
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
190 gb_sets(3), sets(3)
191
192
193
194Ericsson AB stdlib 3.14.1 ordsets(3)