Comparison

util/set.lua @ 11788:1ceee8becb1a

util.set: Add :contains_set() method
author Matthew Wild <mwild1@gmail.com>
date Sun, 12 Sep 2021 10:51:27 +0100
parent 11560:3bbb1af92514
child 12986:895a82c5d8d4
comparison
equal deleted inserted replaced
11787:3ae6fa901a8b 11788:1ceee8becb1a
48 items[item] = true; 48 items[item] = true;
49 end 49 end
50 50
51 function set:contains(item) 51 function set:contains(item)
52 return items[item]; 52 return items[item];
53 end
54
55 function set:contains_set(other_set)
56 for item in other_set do
57 if not self:contains(item) then
58 return false;
59 end
60 end
61 return true;
53 end 62 end
54 63
55 function set:items() 64 function set:items()
56 return next, items; 65 return next, items;
57 end 66 end