diff options
author | Asbjørn Sloth Tønnesen <ast@fiberby.net> | 2017-03-06 10:28:42 +0000 |
---|---|---|
committer | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2017-03-06 10:28:42 +0000 |
commit | ff01073eeee92bf633a15c625d85d940a2e0da52 (patch) | |
tree | 4a03fbc89b7328408b675c6a91de083b5fb4a36a /lua | |
parent | 6799183a66dd850f53ef66af123c82f86abd7602 (diff) | |
download | lua-inet-ff01073eeee92bf633a15c625d85d940a2e0da52.tar.gz lua-inet-ff01073eeee92bf633a15c625d85d940a2e0da52.tar.xz lua-inet-ff01073eeee92bf633a15c625d85d940a2e0da52.zip |
set: aggregate: also dedup
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Diffstat (limited to 'lua')
-rw-r--r-- | lua/inet/set.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lua/inet/set.lua b/lua/inet/set.lua index effb0f2..27c9388 100644 --- a/lua/inet/set.lua +++ b/lua/inet/set.lua @@ -33,11 +33,17 @@ function M.aggregate(t) if ia then local ib = ia:flip() -- counterpart for j=1,n do - if j ~= i and t[j] == ib then - -- counterpart found, aggregating - t[i] = (ia ^ -1):network() - t[j] = nil - flag = true + if j ~= i then + if ia == t[j] then + -- duplicate found + t[j] = nil + flag = true + elseif t[j] == ib then + -- counterpart found, aggregating + t[i] = (ia ^ -1):network() + t[j] = nil + flag = true + end end end end |