|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jsr166e.extra.ReadMostlyVector<E>
public class ReadMostlyVector<E>
A class with the same methods and array-based characteristics as
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>)
.
Constructor Summary | |
---|---|
ReadMostlyVector()
Creates an empty vector with an underlying array of size 10 . |
|
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. |
Method Summary | ||
---|---|---|
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)
See Vector.addElement(E) |
|
boolean |
addIfAbsent(E e)
Appends the element, if not present. |
|
int |
capacity()
See Vector.capacity() |
|
void |
clear()
|
|
ReadMostlyVector<E> |
clone()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
void |
copyInto(Object[] anArray)
See Vector.copyInto(java.lang.Object[]) |
|
E |
elementAt(int index)
See Vector.elementAt(int) |
|
Enumeration<E> |
elements()
See Vector.elements() |
|
void |
ensureCapacity(int minCapacity)
See Vector.ensureCapacity(int) |
|
boolean |
equals(Object o)
|
|
E |
firstElement()
See Vector.firstElement() |
|
E |
get(int index)
|
|
int |
hashCode()
|
|
int |
indexOf(Object o)
|
|
int |
indexOf(Object o,
int index)
See Vector.indexOf(Object, int) |
|
void |
insertElementAt(E obj,
int index)
See Vector.insertElementAt(E, int) |
|
boolean |
isEmpty()
|
|
Iterator<E> |
iterator()
|
|
E |
lastElement()
See Vector.lastElement() |
|
int |
lastIndexOf(Object o)
|
|
int |
lastIndexOf(Object o,
int index)
See Vector.lastIndexOf(Object, int) |
|
ListIterator<E> |
listIterator()
|
|
ListIterator<E> |
listIterator(int index)
|
|
E |
remove(int index)
|
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
void |
removeAllElements()
See Vector.removeAllElements() |
|
boolean |
removeElement(Object obj)
See Vector.removeElement(java.lang.Object) |
|
void |
removeElementAt(int index)
See Vector.removeElementAt(int) |
|
boolean |
retainAll(Collection<?> c)
|
|
E |
set(int index,
E element)
|
|
void |
setElementAt(E obj,
int index)
See Vector.setElementAt(E, int) |
|
void |
setSize(int newSize)
See Vector.setSize(int) |
|
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()
|
|
|
toArray(T[] a)
|
|
String |
toString()
|
|
void |
trimToSize()
See Vector.trimToSize() |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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 array
IllegalArgumentException
- if initial capacity is negativepublic ReadMostlyVector()
10
.
public ReadMostlyVector(Collection<? extends E> c)
c
- the collection of initially held elements
NullPointerException
- if the specified collection is nullMethod Detail |
---|
public boolean add(E e)
add
in interface Collection<E>
add
in interface List<E>
public void add(int index, E element)
add
in interface List<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface List<E>
public boolean addAll(int index, Collection<? extends E> c)
addAll
in interface List<E>
public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in interface List<E>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in interface List<E>
public boolean equals(Object o)
equals
in interface Collection<E>
equals
in interface List<E>
equals
in class Object
public E get(int index)
get
in interface List<E>
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in interface List<E>
hashCode
in class Object
public int indexOf(Object o)
indexOf
in interface List<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface List<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in interface List<E>
public int lastIndexOf(Object o)
lastIndexOf
in interface List<E>
public ListIterator<E> listIterator()
listIterator
in interface List<E>
public ListIterator<E> listIterator(int index)
listIterator
in interface List<E>
public E remove(int index)
remove
in interface List<E>
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface List<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
removeAll
in interface List<E>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
retainAll
in interface List<E>
public E set(int index, E element)
set
in interface List<E>
public int size()
size
in interface Collection<E>
size
in interface List<E>
public List<E> subList(int fromIndex, int toIndex)
subList
in interface List<E>
public Object[] toArray()
toArray
in interface Collection<E>
toArray
in interface List<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in interface List<E>
public String toString()
toString
in class Object
public boolean addIfAbsent(E e)
e
- element to be added to this list, if absent
true
if the element was addedpublic int addAllAbsent(Collection<? extends E> c)
c
- collection containing elements to be added to this list
NullPointerException
- if the specified collection is nulladdIfAbsent(Object)
public Iterator<E> snapshotIterator()
remove
method.
public E firstElement()
Vector.firstElement()
public E lastElement()
Vector.lastElement()
public int indexOf(Object o, int index)
Vector.indexOf(Object, int)
public int lastIndexOf(Object o, int index)
Vector.lastIndexOf(Object, int)
public void setSize(int newSize)
Vector.setSize(int)
public void copyInto(Object[] anArray)
Vector.copyInto(java.lang.Object[])
public void trimToSize()
Vector.trimToSize()
public void ensureCapacity(int minCapacity)
Vector.ensureCapacity(int)
public Enumeration<E> elements()
Vector.elements()
public int capacity()
Vector.capacity()
public E elementAt(int index)
Vector.elementAt(int)
public void setElementAt(E obj, int index)
Vector.setElementAt(E, int)
public void removeElementAt(int index)
Vector.removeElementAt(int)
public void insertElementAt(E obj, int index)
Vector.insertElementAt(E, int)
public void addElement(E obj)
Vector.addElement(E)
public boolean removeElement(Object obj)
Vector.removeElement(java.lang.Object)
public void removeAllElements()
Vector.removeAllElements()
public ReadMostlyVector<E> clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |