1) Look again; it's O(1) work per entry, or O(n) work for an n-entry
directory. And O(1) space. With very small constant factors, and
very little code. The only thing exponentially increasing is the
interval at which you save the current cookie for future comparison.
2) You said it *was* a problem, so it seemed worth presenting a
practical solution. If you don't think it's worth it, I'm not
going to disagree. But it's not impossible, or even difficult.
--