-- Penlight 1.11.0-1 | /lua/pl/Set.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.tablex'local b=require'pl.utils'local c,d=b.array_tostring,table.concat;local e,f=a.merge,a.difference;local g=require'pl.Map'local h=require'pl.class'local i=b.stdmt;local j=i.Set;h(g,nil,j)j.__index=nil;local function k(l)return setmetatable(l,j)end;function j:_init(l)l=l or{}local m=getmetatable(l)if m==j or m==g then for n in pairs(l)do self[n]=true end else for o,p in ipairs(l)do self[p]=true end end end;function j:__tostring()return'['..d(c(j.values(self)),',')..']'end;j.values=g.keys;function j.map(self,q,...)q=b.function_arg(1,q)local r={}for n in pairs(self)do r[q(n,...)]=true end;return k(r)end;function j.union(self,s)return e(self,s,true)end;local function t(self,u)local m=getmetatable(u)if m==j or m==g then return j.union(self,u)else local v=j(self)v[u]=true;return v end end;j.__add=t;function j.intersection(self,s)return e(self,s,false)end;j.__mul=j.intersection;function j.difference(self,s)return f(self,s,false)end;local function w(self,u)local m=getmetatable(u)if m==j or m==g then return j.difference(self,u)else local v=j(self)v[u]=nil;return v end end;j.__sub=w;function j.symmetric_difference(self,s)return f(self,s,true)end;j.__pow=j.symmetric_difference;function j.issubset(self,s)for n in pairs(self)do if not s[n]then return false end end;return true end;j.__lt=j.issubset;function j.isempty(self)return next(self)==nil end;function j.isdisjoint(x,y)return j.isempty(j.intersection(x,y))end;j.len=a.size;j.__len=j.len;function j.__eq(x,y)return j.issubset(x,y)and j.issubset(y,x)end;return j
