equal
deleted
inserted
replaced
28 local a, i = {}, 1; |
28 local a, i = {}, 1; |
29 for item in self._items do |
29 for item in self._items do |
30 a[i], i = item, i+1; |
30 a[i], i = item, i+1; |
31 end |
31 end |
32 return a; |
32 return a; |
|
33 end |
|
34 |
|
35 local function is_set(o) |
|
36 local mt = getmetatable(o); |
|
37 return mt == set_mt; |
33 end |
38 end |
34 |
39 |
35 local function new(list) |
40 local function new(list) |
36 local items = setmetatable({}, items_mt); |
41 local items = setmetatable({}, items_mt); |
37 local set = { _items = items }; |
42 local set = { _items = items }; |
175 return t_concat(s, ", "); |
180 return t_concat(s, ", "); |
176 end |
181 end |
177 |
182 |
178 return { |
183 return { |
179 new = new; |
184 new = new; |
|
185 is_set = is_set; |
180 union = union; |
186 union = union; |
181 difference = difference; |
187 difference = difference; |
182 intersection = intersection; |
188 intersection = intersection; |
183 xor = xor; |
189 xor = xor; |
184 }; |
190 }; |