info.monitorenter.util.collections
Class TreeSetGreedy
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
java.util.TreeSet
info.monitorenter.util.collections.TreeSetGreedy
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable, Collection, Set, SortedSet
public class TreeSetGreedy
- extends TreeSet
- implements Set
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:
- Serialized Form
Constructor Summary |
TreeSetGreedy()
Creates an instance with an internal Comparator to fulfill the contract of this
class. |
Methods inherited from class java.util.TreeSet |
addAll, clear, clone, comparator, contains, first, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet |
Methods inherited from interface java.util.Set |
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
TreeSetGreedy
public TreeSetGreedy()
- Creates an instance with an internal
Comparator
to fulfill the contract of this
class.
add
public boolean add(Object o)
- Specified by:
add
in interface Collection
- Specified by:
add
in interface Set
- Overrides:
add
in class TreeSet
- See Also:
Collection.add(java.lang.Object)
Copyright © 2001 - 2007 LGPL, All Rights Footloose.