From 11191e8d4cb1684e46a65a89ddc81a7fdaf93db7 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 21 Jun 2026 16:44:49 -0500 Subject: [PATCH] Added tContains and tDeleteItem --- AddOns/!!!ClassicAPI/Util/TableUtil.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/AddOns/!!!ClassicAPI/Util/TableUtil.lua b/AddOns/!!!ClassicAPI/Util/TableUtil.lua index 1a0dd387..e989188c 100644 --- a/AddOns/!!!ClassicAPI/Util/TableUtil.lua +++ b/AddOns/!!!ClassicAPI/Util/TableUtil.lua @@ -65,6 +65,18 @@ function CreateTableReverseEnumerator(tbl, minIndex, maxIndex) return Enumerator, tbl, maxIndex end +function tDeleteItem(tbl, item) + local size = #tbl; + local index = size; + while index > 0 do + if item == tbl[index] then + tRemove(tbl, index); + end + index = index - 1; + end + return size - #tbl; +end + function tIndexOf(tbl, item) for i, v in ipairs(tbl) do if item == v then @@ -73,6 +85,15 @@ function tIndexOf(tbl, item) end end +function tContains(tbl, item) + for k, v in pairs(tbl) do + if item == v then + return true; + end + end + return false; +end + function TableUtil.ContainsAllKeys(lhsTable, rhsTable) for key, _ in pairs(lhsTable) do if rhsTable[key] == nil then