Created
May 10, 2023 15:09
-
-
Save PRotondo/275a1292cd0b4cc08064211f2e600dc1 to your computer and use it in GitHub Desktop.
Worst case scenarios for the Lua hybrid tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k = 15 | |
m = 1<<k | |
tab = {} | |
pow2 = m<<2 -- any power of two larger works | |
for i=1,m do | |
tab[pow2+i] = 1 -- insert big elements | |
end | |
for i=1,m do | |
tab[pow2+i] = nil -- delete first | |
tab[pow2+m+1+i] = 1 -- insert new | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k = 24 | |
m = 1<<k | |
tab = {} | |
for i=(-m+1),m do | |
tab[i] = 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment