[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: problem with lists and weak references in pure LUA
- From: Mark Hamburg <mhamburg@...>
- Date: Wed, 27 Oct 2004 08:58:45 -0700
Keep a sorted array of priority sets. Adding an element consists of a binary
search for an existing set and an insertion into the array if one isn't
present. During message processing, you can delete empty sets if you have
lots of flux in priority values. On the other hand, if values are likely to
be reused, then you can just leave the empty sets in place figuring they
will become non-empty later.
If you want to use a linked list to avoid the cost of insertion into an
array, then use a linked list of backbone nodes that point to weak sets.
That's probably only worthwhile, however, if you have a lot of priority
values active at any one time since insertion into an array while
proportional on average to half the array length has a fairly small
proportionality constant.
Mark