E
- A class implementing Comparable
or able to be
compared by a provided comparator.@InterfaceAudience.Private public class SortedCopyOnWriteSet<E> extends Object implements SortedSet<E>
SortedSet
implementation that uses an internal
TreeSet
to provide ordering. All mutation operations
create a new copy of the TreeSet
instance, so are very
expensive. This class is only intended for use on small, very rarely
written collections that expect highly concurrent reads. Read operations
are performed on a reference to the internal TreeSet
at the
time of invocation, so will not see any mutations to the collection during
their operation.
Note that due to the use of a TreeSet
internally,
a Comparator
instance must be provided, or collection
elements must implement Comparable
.
Constructor and Description |
---|
SortedCopyOnWriteSet() |
SortedCopyOnWriteSet(Collection<? extends E> c) |
SortedCopyOnWriteSet(Comparator<? super E> comparator) |
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) |
public SortedCopyOnWriteSet()
public SortedCopyOnWriteSet(Collection<? extends E> c)
public SortedCopyOnWriteSet(Comparator<? super E> comparator)
public int size()
public boolean isEmpty()
public boolean contains(Object o)
public Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean add(E e)
public boolean remove(Object o)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
public boolean addAll(Collection<? extends E> c)
public boolean retainAll(Collection<?> c)
public boolean removeAll(Collection<?> c)
public void clear()
public Comparator<? super E> comparator()
comparator
in interface SortedSet<E>
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.