public class ReadMostlyVector<E> extends Object implements List<E>, RandomAccess, Cloneable, Serializable
Vector but with reduced contention and improved throughput
when invocations of read-only methods by multiple threads are most common.
The iterators returned by this class's iterator and listIterator methods are best-effort
in the presence of concurrent modifications, and do
NOT throw ConcurrentModificationException. An iterator's
next() method returns consecutive elements as they appear in the
underlying array upon each access. Alternatively, method
snapshotIterator() may be used for deterministic traversals, at the
expense of making a copy, and unavailability of method
Iterator.remove.
Otherwise, this class supports all methods, under the same documented
specifications, as Vector. Consult Vector for detailed specifications. Additionally, this class
provides methods addIfAbsent(E) and addAllAbsent(java.util.Collection<? extends E>).
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
ReadMostlyVector.Action<A>
Interface describing a void action of one argument
|
| 构造器和说明 |
|---|
ReadMostlyVector()
Creates an empty vector.
|
ReadMostlyVector(Collection<? extends E> c)
Creates a vector containing the elements of the specified collection, in
the order they are returned by the collection's iterator.
|
ReadMostlyVector(int initialCapacity)
Creates an empty vector with the given initial capacity.
|
ReadMostlyVector(int initialCapacity,
int capacityIncrement)
Creates an empty vector with the given initial capacity and capacity
increment.
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(E e) |
void |
add(int index,
E element) |
boolean |
addAll(Collection<? extends E> c) |
boolean |
addAll(int index,
Collection<? extends E> c) |
int |
addAllAbsent(Collection<? extends E> c)
Appends all of the elements in the specified collection that are not
already contained in this list, to the end of this list, in the order
that they are returned by the specified collection's iterator.
|
void |
addElement(E obj)
|
boolean |
addIfAbsent(E e)
Appends the element, if not present.
|
int |
capacity()
|
void |
clear() |
ReadMostlyVector<E> |
clone() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
void |
copyInto(Object[] anArray)
|
E |
elementAt(int index)
|
Enumeration<E> |
elements()
|
void |
ensureCapacity(int minCapacity)
|
boolean |
equals(Object o) |
E |
firstElement()
|
void |
forEachReadOnly(ReadMostlyVector.Action<E> action) |
E |
get(int index) |
int |
hashCode() |
int |
indexOf(Object o) |
int |
indexOf(Object o,
int index)
|
void |
insertElementAt(E obj,
int index)
|
boolean |
isEmpty() |
Iterator<E> |
iterator() |
E |
lastElement()
|
int |
lastIndexOf(Object o) |
int |
lastIndexOf(Object o,
int index)
|
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
E |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
void |
removeAllElements()
|
boolean |
removeElement(Object obj)
|
void |
removeElementAt(int index)
|
boolean |
retainAll(Collection<?> c) |
E |
set(int index,
E element) |
void |
setElementAt(E obj,
int index)
|
void |
setSize(int newSize)
|
int |
size() |
Iterator<E> |
snapshotIterator()
Returns an iterator operating over a snapshot copy of the elements of
this collection created upon construction of the iterator.
|
List<E> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
void |
trimToSize()
|
public ReadMostlyVector(int initialCapacity,
int capacityIncrement)
initialCapacity - the initial capacity of the underlying arraycapacityIncrement - if non-zero, the number to add when resizing to
accommodate additional elements. If zero, the array size is doubled when
resized.IllegalArgumentException - if initial capacity is negativepublic ReadMostlyVector(int initialCapacity)
initialCapacity - the initial capacity of the underlying arrayIllegalArgumentException - if initial capacity is negativepublic ReadMostlyVector()
public ReadMostlyVector(Collection<? extends E> c)
c - the collection of initially held elementsNullPointerException - if the specified collection is nullpublic boolean addAll(Collection<? extends E> c)
public boolean addAll(int index,
Collection<? extends E> c)
public boolean contains(Object o)
public boolean containsAll(Collection<?> c)
containsAll 在接口中 Collection<E>containsAll 在接口中 List<E>public boolean equals(Object o)
public int hashCode()
public int lastIndexOf(Object o)
lastIndexOf 在接口中 List<E>public ListIterator<E> listIterator()
listIterator 在接口中 List<E>public ListIterator<E> listIterator(int index)
listIterator 在接口中 List<E>public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public boolean addIfAbsent(E e)
e - element to be added to this list, if absenttrue if the element was addedpublic int addAllAbsent(Collection<? extends E> c)
c - collection containing elements to be added to this listNullPointerException - if the specified collection is nulladdIfAbsent(Object)public Iterator<E> snapshotIterator()
remove method.public void forEachReadOnly(ReadMostlyVector.Action<E> action)
public E firstElement()
public E lastElement()
public int indexOf(Object o, int index)
public int lastIndexOf(Object o, int index)
public void setSize(int newSize)
public void copyInto(Object[] anArray)
public void trimToSize()
public void ensureCapacity(int minCapacity)
public Enumeration<E> elements()
public int capacity()
public E elementAt(int index)
public void setElementAt(E obj, int index)
public void removeElementAt(int index)
public void insertElementAt(E obj, int index)
public void addElement(E obj)
public boolean removeElement(Object obj)
public void removeAllElements()
public ReadMostlyVector<E> clone()
Copyright © 2013 The Skfiy Open Association. All Rights Reserved.