map = {} local this = map function clone(object) local lookup_table = {} local function _copy(object) if type(object) ~= "table" then return object elseif lookup_table[object] then return lookup_table[object] end local newObject = {} lookup_table[object] = newObject for key, value in pairs(object) do newObject[_copy(key)] = _copy(value) end return setmetatable(newObject, getmetatable(object)) end return _copy(object) end function this:new() o = {} setmetatable(o,self) self.__index = self self.count = 0 return o end function this:insert(k,v) if nil == self[k] then self[k] = clone(v) self.count = self.count + 1 end end function this:remove(k) if nil ~= self[k] then self[k] = nil if self.count >0 then self.count = self.count - 1 end end end function this:getpair(k) local value = nil if nil ~= self[k] then value = self[k] end return value end function this:clear() for k,_ in pairs(self) do if nil ~= self[k] then self[k] = nil end end self.count = 0 end