T
- the type of instances to store.public class TreeSetGreedy<T extends IComparableProperty> extends TreeSet<T> implements Set<T>
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
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 and Description |
---|
TreeSetGreedy()
Creates an instance with an internal
Comparator to fulfill the
contract of this class. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T o)
Attempts to add the the given
T . |
boolean |
remove(Object o) |
addAll, ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, size, spliterator, subSet, subSet, tailSet, tailSet
equals, hashCode, removeAll
containsAll, retainAll, toArray, toArray, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, spliterator, toArray, toArray
parallelStream, removeIf, stream
public TreeSetGreedy()
Comparator
to fulfill the
contract of this class.public boolean add(T o)
T
.
add
in interface Collection<T extends IComparableProperty>
add
in interface Set<T extends IComparableProperty>
add
in class TreeSet<T extends IComparableProperty>
o
- the T to add.TreeSet.add(java.lang.Object)
public boolean remove(Object o)
remove
in interface Collection<T extends IComparableProperty>
remove
in interface Set<T extends IComparableProperty>
remove
in class TreeSet<T extends IComparableProperty>
TreeSet.remove(java.lang.Object)
Copyright © 2017. All rights reserved.