VE Lua Documentation

Press F to search!

setDifference

Definition


-- @/lua/common/utils.lua:529

-- removes from dst array, all values in src array. It changes the order of dst
function setDifference(dst, src)
  local srcByValue = table.new(0, #src)
  for _, v in ipairs(src) do
    srcByValue[v] = true
  end
  local dstBack = #dst
  for i = dstBack, 1, -1 do
    if srcByValue[dst[i]] then
      dst[i] = dst[dstBack]
      dst[dstBack] = nil
      dstBack = dstBack - 1
    end
  end
  return dst
end

Callers