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
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

DATA TYPES

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

EXPORTS

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

SEE ALSO

182       gb_sets(3), sets(3)
183
184
185
186Ericsson AB                     stdlib 3.4.5.1                      ordsets(3)
Impressum