Class TreeSetGreedy<T extends IComparableProperty>

java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractSet<T>
java.util.TreeSet<T>
info.monitorenter.util.collections.TreeSetGreedy<T>
Type Parameters:
T - the type of instances to store.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, NavigableSet<T>, SequencedCollection<T>, SequencedSet<T>, Set<T>, SortedSet<T>

public class TreeSetGreedy<T extends IComparableProperty> extends TreeSet<T> implements Set<T>
A Set that will always successfully add new instances and guarantee that all the "Comparable properties" of the contained IComparableProperty instances will build a set (no duplicates).

Although the interface of Set is preserved and allows adding any Object only IComparableProperty instances may be added to TreeSetGreedy because it uses a proprietary Comparator.

The added IComparableProperty instances with the lowest Number property (see IComparableProperty.getComparableProperty() ) will be returned first from the retrievable Iterator

Warning

If the IComparableProperty (thus meaning the member or accessed data) is changed from outside, the internal order of this set will get corrupted and iterations or add/remove calls may fail. Therefore it is necessary to remove the instance before outside modification and later on add it again.

Author:
Achim Westermann
See Also: