mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
documented table utils
This commit is contained in:
parent
bf258ab15a
commit
2a4d57cd6f
1 changed files with 6 additions and 0 deletions
|
|
@ -3902,6 +3902,11 @@ end
|
|||
|
||||
-- ###########################################
|
||||
|
||||
--- Perform a linear search to check if an element is inside a table
|
||||
--- @param t table The table to scan
|
||||
--- @param needle any The element to search
|
||||
--- @param comp function The compare function used to compare the searched element with others
|
||||
--- @return boolean True if the element is insie the table, False otherwise
|
||||
function table.contains(t, needle, comp)
|
||||
|
||||
if (t == nil) then return false end
|
||||
|
|
@ -3919,6 +3924,7 @@ end
|
|||
|
||||
-- ###########################################
|
||||
|
||||
--- Insert an element inside the table if is not present
|
||||
function table.insertIfNotPresent(t, element, comp)
|
||||
if table.contains(t, element, comp) then return end
|
||||
t[#t+1] = element
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue