@InterfaceAudience.Private public class SortedList<E> extends Object implements List<E>, RandomAccess
ArrayList as
the underlying collection so we can support RandomAccess. All mutations
create a new copy of the ArrayList instance, so can be
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 list at the time of invocation, so will not see any mutations to the collection during their operation. Iterating over list elements manually using the RandomAccess pattern involves multiple operations. For this to be safe get a reference to the internal list first using get().
If constructed with a Comparator, the list will be sorted
using the comparator. Adding or changing an element using an index will
trigger a resort.
Iterators are read-only. They cannot be used to remove elements.
| 构造器和说明 |
|---|
SortedList(Collection<? extends E> c,
Comparator<? super E> comparator)
Constructs a list containing the elements of the given collection, in the
order returned by the collection's iterator, that will be sorted with the
given comparator.
|
SortedList(Comparator<? super E> comparator)
Constructs an empty list with the default initial capacity that will be
sorted using the given comparator.
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(E e) |
void |
add(int index,
E element) |
boolean |
addAll(Collection<? extends E> c) |
boolean |
addAll(int index,
Collection<? extends E> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
List<E> |
get()
Returns a reference to the unmodifiable list currently backing the SortedList.
|
E |
get(int index) |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
E |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
E |
set(int index,
E element) |
int |
size() |
List<E> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequals, hashCode, replaceAll, sort, spliteratorparallelStream, removeIf, streampublic SortedList(Comparator<? super E> comparator)
comparator - the comparatorpublic SortedList(Collection<? extends E> c, Comparator<? super E> comparator)
c - the collectioncomparator - the comparatorpublic List<E> get()
public boolean contains(Object o)
public boolean containsAll(Collection<?> c)
containsAll 在接口中 Collection<E>containsAll 在接口中 List<E>public boolean addAll(Collection<? extends E> c)
public boolean addAll(int index,
Collection<? extends E> c)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public int lastIndexOf(Object o)
lastIndexOf 在接口中 List<E>public ListIterator<E> listIterator()
listIterator 在接口中 List<E>public ListIterator<E> listIterator(int index)
listIterator 在接口中 List<E>Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.