|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractSet<E> java.util.TreeSet<T> info.monitorenter.util.collections.TreeSetGreedy<T>
T
- the type of instances to store.public class TreeSetGreedy<T extends IComparableProperty>
A Set
that will always successfully add new instances and
guarantee that all the "Comparable properties" of the contained
instances will build a set (no duplicates).
IComparableProperty
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
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.
Constructor Summary | |
---|---|
TreeSetGreedy()
Creates an instance with an internal Comparator to fulfill the
contract of this class. |
Method Summary | |
---|---|
boolean |
add(T o)
Attempts to add the the given T . |
boolean |
remove(java.lang.Object o)
|
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, subSet, subSet, tailSet, tailSet |
Methods inherited from class java.util.AbstractSet |
---|
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray |
Constructor Detail |
---|
public TreeSetGreedy()
Comparator
to fulfill the
contract of this class.
Method Detail |
---|
public boolean add(T o)
T
.
add
in interface java.util.Collection<T extends IComparableProperty>
add
in interface java.util.Set<T extends IComparableProperty>
add
in class java.util.TreeSet<T extends IComparableProperty>
o
- the T to add.
TreeSet.add(java.lang.Object)
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<T extends IComparableProperty>
remove
in interface java.util.Set<T extends IComparableProperty>
remove
in class java.util.TreeSet<T extends IComparableProperty>
TreeSet.remove(java.lang.Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |