Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class ArraySortedSet<E> extends AbstractSet<E> implements SortedSet<E>, Serializable
A compact SortedSet implementation that stores the elements in order.
The emphasis is to use as little heap space as possible - this is not a general-purpose
SortedSet implementation as it has specific constraints about the order elements
may be added or removed. To avoid the possibility of O(n^2) behavior, the elements must
already be sorted and be added in ascending order. Also, only the last element may be
removed.
This set does not support null values.
Creation of a set for an already sorted set is O(n) compared to TreeSet's O(n log n). Other operations perform at O(log n) with times very similar to TreeSet.
This set is not thread safe.
| Constructor and Description |
|---|
ArraySortedSet() |
ArraySortedSet(Collection<? extends E> c) |
ArraySortedSet(Comparator<? super E> comparator) |
ArraySortedSet(Comparator<? super E> comparator,
int initialCapacity) |
ArraySortedSet(int initialCapacity) |
ArraySortedSet(SortedSet<E> s) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
void |
clear() |
Comparator<? super E> |
comparator() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
E |
first() |
SortedSet<E> |
headSet(E toElement) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
E |
last() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
SortedSet<E> |
subSet(E fromElement,
E toElement) |
SortedSet<E> |
tailSet(E fromElement) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
void |
trimToSize() |
equals, hashCodetoStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitspliteratorparallelStream, removeIf, streampublic ArraySortedSet()
public ArraySortedSet(int initialCapacity)
public ArraySortedSet(Comparator<? super E> comparator)
public ArraySortedSet(Comparator<? super E> comparator, int initialCapacity)
public ArraySortedSet(Collection<? extends E> c)
public void trimToSize()
public Comparator<? super E> comparator()
comparator in interface SortedSet<E>public int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public boolean add(E e)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in interface Set<E>containsAll in class AbstractCollection<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in interface Set<E>addAll in class AbstractCollection<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in interface Set<E>retainAll in class AbstractCollection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in interface Set<E>removeAll in class AbstractSet<E>public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.