Package org.drasyl.util
Class InconsistentSortedSet<E>
java.lang.Object
org.drasyl.util.InconsistentSortedSet<E>
- Type Parameters:
- E- the type of elements maintained by this set
- All Implemented Interfaces:
- Iterable<E>,- Collection<E>,- Set<E>,- SortedSet<E>
A 
SortedSet where elements are ordered using their
 natural ordering, or by a Comparator provided at set creation
 time, depending on which constructor is used.
 
 Unlike TreeSet, ordering does not have to be consistent with equals. In
 other words, TreeSet implies that objects are equal if
 Comparable.compareTo(Object) returns 0. In contrast,
 InconsistentSortedSet uses Object.equals(Object) to determine equality.
 
 Here an example which cannot be handled by TreeSet but from
 InconsistentSortedSet:
Assume the DAO class Person with attributes
 name and height. Now assume a data structure containing a set of Persons
 where each name should be unique, and the elements should be sorted by height.
 
 Internally, this class is backed by a HashSet and ArrayUtil, so the memory
 consumption of this class is probably equal to the sum of these two classes.
- 
Constructor SummaryConstructorsConstructorDescriptionInconsistentSortedSet(int initialCapacity) InconsistentSortedSet(Collection<? extends E> c) Constructs a new set containing the elements in the specified collection.InconsistentSortedSet(Comparator<? super E> comparator) Constructs a new, empty set, ordered according to the given comparator.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> c) voidclear()Comparator<? super E>booleanbooleancontainsAll(Collection<?> c) first()booleanisEmpty()iterator()last()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.SortedSetspliterator
- 
Constructor Details- 
InconsistentSortedSetpublic InconsistentSortedSet()
- 
InconsistentSortedSetConstructs a new set containing the elements in the specified collection.- Parameters:
- c- the collection whose elements are to be placed into this set
- Throws:
- NullPointerException- if the specified collection is- null
 
- 
InconsistentSortedSetpublic InconsistentSortedSet(int initialCapacity) Constructs a new, empty set; the backingHashSetandArrayListinstances have the specified initial capacity.- Parameters:
- initialCapacity- the initial capacity of the hash set and array list
 
- 
InconsistentSortedSetConstructs a new, empty set, ordered according to the given comparator. All keys inserted into the map must be mutually comparable by the given comparator:comparator.compare(k1, k2)must not throw aClassCastExceptionfor any elementsk1andk2in the set. If the user attempts to put an element into the set that violates this constraint, theput(Object key, Object value)call will throw aClassCastException.- Parameters:
- comparator- the comparator that will be used to order this set. If- null, the natural ordering of the keys will be used.
 
 
- 
- 
Method Details- 
sizepublic int size()
- 
isEmptypublic boolean isEmpty()
- 
contains
- 
iterator
- 
toArray
- 
toArraypublic <T> T[] toArray(T[] a) 
- 
add
- 
remove
- 
containsAll- Specified by:
- containsAllin interface- Collection<E>
- Specified by:
- containsAllin interface- Set<E>
 
- 
addAll
- 
retainAll
- 
removeAll
- 
clearpublic void clear()
- 
comparator- Specified by:
- comparatorin interface- SortedSet<E>
 
- 
subSet
- 
headSet
- 
tailSet
- 
first
- 
last
 
-