public class SortedArraySet<T>
extends java.lang.Object
implements java.util.SortedSet<T>
Comparator or according to their
implementation of the interface Comparable. In contrast to a TreeSet, two items
are considered as duplicates, if their hash codes are equal, instead of evaluating the result of
the Comparator or Comparable.compareTo(Object) method.
The set internally uses a SortedArrayList to keep the items in a sorted order whenever
updated. In addition the hash codes of all items, which are contained by the set, are maintained
in a HashSet to prevent duplicates from being added to the set.| Constructor and Description |
|---|
SortedArraySet()
Creates a new set, whose items are sorted.
|
SortedArraySet(java.util.Collection<T> items)
Creates a new set, whose items are sorted.
|
SortedArraySet(@NotNull java.util.Collection<T> items,
@Nullable java.util.Comparator<? super T> comparator)
Creates a new set, whose items are sorted.
|
SortedArraySet(@Nullable java.util.Comparator<? super T> comparator)
Creates a new set, whose items are sorted.
|
SortedArraySet(int initialCapacity)
Creates a new set, whose items are sorted.
|
SortedArraySet(int initialCapacity,
@Nullable java.util.Comparator<? super T> comparator)
Creates a new set, whose items are sorted.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T item) |
boolean |
addAll(@NotNull java.util.Collection<? extends T> items) |
void |
clear() |
@Nullable java.util.Comparator<? super T> |
comparator() |
boolean |
contains(@NotNull java.lang.Object item) |
boolean |
containsAll(@NotNull java.util.Collection<?> items) |
boolean |
equals(java.lang.Object obj) |
T |
first() |
int |
hashCode() |
@NotNull java.util.SortedSet<T> |
headSet(T toElement) |
boolean |
isEmpty() |
@NotNull java.util.Iterator<T> |
iterator() |
T |
last() |
boolean |
remove(@NotNull java.lang.Object item) |
boolean |
removeAll(@NotNull java.util.Collection<?> items) |
boolean |
retainAll(@NotNull java.util.Collection<?> items) |
int |
size() |
@NotNull java.util.SortedSet<T> |
subSet(T fromElement,
T toElement) |
@NotNull java.util.SortedSet<T> |
tailSet(T fromElement) |
@NotNull java.lang.Object[] |
toArray() |
<T1> T1[] |
toArray(T1[] array) |
java.lang.String |
toString() |
public SortedArraySet()
Comparable.public SortedArraySet(java.util.Collection<T> items)
Comparable.items - A collection, which contains the items, which should be added to the set, as an
instance of the type Collection or an empty collection, if no items
should be addedpublic SortedArraySet(int initialCapacity)
Comparable.initialCapacity - The initial capacity of the set as an Integer valuepublic SortedArraySet(@Nullable
@Nullable java.util.Comparator<? super T> comparator)
comparator - The comparator, which should be used to sort the set's items, or null, if
the items' implementation of the interface Comparable should be
used insteadpublic SortedArraySet(@NotNull
@NotNull java.util.Collection<T> items,
@Nullable
@Nullable java.util.Comparator<? super T> comparator)
Comparable.items - A collection, which contains the items, which should be added to the set,
as an instance of the type Collection or an empty collection, if no
items should be addedcomparator - The comparator, which should be used to sort the set's items, or null, if
the items' implementation of the interface Comparable should be
used insteadpublic SortedArraySet(int initialCapacity,
@Nullable
@Nullable java.util.Comparator<? super T> comparator)
initialCapacity - The initial capacity of the set as an Integer valuecomparator - The comparator, which should be used to sort the set's items, or null,
if the items' implementation of the interface Comparable
should be used instead@Nullable public final @Nullable java.util.Comparator<? super T> comparator()
comparator in interface java.util.SortedSet<T>@NotNull public final @NotNull java.util.SortedSet<T> subSet(@NotNull T fromElement, @NotNull T toElement)
subSet in interface java.util.SortedSet<T>@NotNull public final @NotNull java.util.SortedSet<T> headSet(@NotNull T toElement)
headSet in interface java.util.SortedSet<T>@NotNull public final @NotNull java.util.SortedSet<T> tailSet(@NotNull T fromElement)
tailSet in interface java.util.SortedSet<T>public final int size()
public final boolean isEmpty()
public final boolean contains(@NotNull
@NotNull java.lang.Object item)
@NotNull public final @NotNull java.util.Iterator<T> iterator()
@NotNull public final @NotNull java.lang.Object[] toArray()
@NotNull
public final <T1> T1[] toArray(@NotNull
T1[] array)
public final boolean add(@NotNull
T item)
public final boolean remove(@NotNull
@NotNull java.lang.Object item)
public final boolean containsAll(@NotNull
@NotNull java.util.Collection<?> items)
public final boolean addAll(@NotNull
@NotNull java.util.Collection<? extends T> items)
public final boolean retainAll(@NotNull
@NotNull java.util.Collection<?> items)
public final boolean removeAll(@NotNull
@NotNull java.util.Collection<?> items)
public final void clear()
public final java.lang.String toString()
toString in class java.lang.Objectpublic final int hashCode()