Class TreeSetGreedy<T extends IComparableProperty>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
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>,Set<T>,SortedSet<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 theIComparableProperty (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:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance with an internalComparatorto fulfill the contract of this class. -
Method Summary
Methods inherited from class java.util.TreeSet
addAll, ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, size, spliterator, subSet, subSet, tailSet, tailSetMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
TreeSetGreedy
public TreeSetGreedy()Creates an instance with an internalComparatorto fulfill the contract of this class.
-
-
Method Details
-
add
Attempts to add the the givenT.- Specified by:
addin interfaceCollection<T extends IComparableProperty>- Specified by:
addin interfaceSet<T extends IComparableProperty>- Overrides:
addin classTreeSet<T extends IComparableProperty>- Parameters:
o- the T to add.- Returns:
- see superclass.
- See Also:
-
remove
- Specified by:
removein interfaceCollection<T extends IComparableProperty>- Specified by:
removein interfaceSet<T extends IComparableProperty>- Overrides:
removein classTreeSet<T extends IComparableProperty>- See Also:
-