Software /
code /
prosody
Comparison
util/set.lua @ 11560:3bbb1af92514
Merge 0.11->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 13 May 2021 11:17:13 +0100 |
parent | 10594:13d5fb74648f |
parent | 11542:c358537c0878 |
child | 11788:1ceee8becb1a |
comparison
equal
deleted
inserted
replaced
11538:30feeb4d9d0b | 11560:3bbb1af92514 |
---|---|
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 }; |