Skip to content

Instantly share code, notes, and snippets.

@jxe
jxe / Chatterbase.carbide.md
Last active August 3, 2018 00:41
Chatterbase

Chatterbase

@lukego
lukego / gist:4706097
Last active December 12, 2015 03:19
Table data structure that "garbage collects" not-recently-used items in O(1) time

I use this data structure all the time. Can someone leave a comment and tell me what it's called?

  1. insert(k,v): add a new value
  2. lookup(k): lookup an existing value
  3. age(): delete old entries (that have not been used since previous call to age())
# Initialize 'old' and 'new' to empty tables
local old, new = {}, {}