Yes, but if you first compare the new item with the smallest of the 10 already stored, you will very rarely add it to the set of 10 and re-sort. This would be a "conditionally discard, add, and re-sort" algorithm.
In reply to Re^2: Limit the size of a hash (beware of 'add one and (re)sort and discard' algorithms)
by hdb
in thread Limit the size of a hash
by Dr Manhattan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |