local next = next
local pairs = pairs
local ipairs = ipairs
local type = type
local _ENV = {}
local tcopy_local
function tcopy (t)
  local tc = {};
  for k,v in pairs(t) do
    if type(v) == "table" then
      tc[k] = tcopy_local(v);
    else
      tc[k] = v;
    end
  end
  return tc;
end
tcopy_local = tcopy
function shallow_tcopy(t)
  local k = next(t)
  local out = {}
  while k do
    out[k] = t[k]
    k = next(t, k)
  end
  return out
end
function invert(t)
  local out = {}
  for k, v in pairs(t) do
    out[v] = k
  end
  return out
end
function contains(t, item, array)
  local iter = array and ipairs or pairs
  for k, val in iter(t) do
    if val == item then
      return true, k
    end
  end
  return false, nil
end
function keys(t)
  local ret = {}
  local k, v = next(t)
  while k ~= nil do
    ret[#ret+1] = k
    k, v = next(t, k)
  end
  return ret
end
return _ENV
