// always keeps a dynamically updated list of the n most probable // results // not synchronized sclass SetOfMostProbable extends TreeSetWithDuplicates> { int maxSize = 10; *() {} *(int *maxSize) {} public bool add(WithProbability a) { if (a == null) false; super.add(a); truncate(); true; } void setMaxSize(int *maxSize) { truncate(); } void truncate { truncateTreeSetWithDuplicates(this, maxSize); } }