[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tracking number of pairs in a dictionary
- From: Jorge <xxopxe@...>
- Date: Thu, 01 Oct 2009 13:09:28 -0300
On Wed, 2009-09-30 at 23:34 +0200, Michal Kolodziejczyk wrote:
> Or you could keep a counter within the table (so you will not iterate
> the table at all). Here is an example implementation (you can overide
> removeOne() to what you need):
>
> MT={
> add=function(self, key, value)
Wow... Never seen metatables used like that. Had to look it twice to get
why it works :)
Is there a way for keeping _n and _limit out of the table? With some
upvalue magic or something? Otherwise you have to explicitly skip them
while iterating (as the RemoveOne as is does not :) )
Jorge