|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractList
java.util.Vector
com.taco.data.ListToVectorAdapter
public class ListToVectorAdapter
An adapter from an ArrayList
to a Vector
, which
allows interoperability with legacy code that expects instances of
Vector
without the performance hit due to the synchronization
of methods. Obviously, none of the methods of this class are synchronized!
Field Summary | |
---|---|
protected java.util.ArrayList |
_arrayList
If the _list is an instance of ArrayList ,
this field is set to the casted version of _list . |
protected java.util.List |
_list
The list that this instance decorates. |
static ICollectionFactory |
LIST_TO_VECTOR_ADAPTER_FACTORY
A collection factory that creates instances of this class. |
Fields inherited from class java.util.Vector |
---|
capacityIncrement, elementCount, elementData |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
ListToVectorAdapter()
Construct a new instance, which is initially empty, and decorates a new ArrayList . |
|
ListToVectorAdapter(java.util.Collection c)
Construct a new instance that has the elements of c . |
|
ListToVectorAdapter(java.util.Collection c,
boolean copy)
Construct a new instance that has the elements of c . |
|
ListToVectorAdapter(int capacity)
Construct a new instance, which is initially empty, and decorates a new ArrayList . |
Method Summary | |
---|---|
void |
add(int index,
java.lang.Object element)
|
boolean |
add(java.lang.Object o)
|
boolean |
addAll(java.util.Collection c)
|
boolean |
addAll(int index,
java.util.Collection c)
|
void |
addElement(java.lang.Object obj)
|
int |
capacity()
Return the size of the decorated list, since there's no way to get the capacity of a List or ArrayList . |
void |
clear()
|
java.lang.Object |
clone()
Clone this instance by cloning the decorated list. |
boolean |
contains(java.lang.Object elem)
|
boolean |
containsAll(java.util.Collection c)
|
void |
copyInto(java.lang.Object[] anArray)
|
java.lang.Object |
elementAt(int index)
|
java.util.Enumeration |
elements()
|
void |
ensureCapacity(int minCapacity)
If this instance is decorating an instance of ArrayList ,
call ensureCapacity() on it. |
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
firstElement()
|
java.lang.Object |
get(int index)
|
int |
hashCode()
|
int |
indexOf(java.lang.Object elem)
|
int |
indexOf(java.lang.Object elem,
int index)
|
void |
insertElementAt(java.lang.Object obj,
int index)
|
boolean |
isEmpty()
|
java.lang.Object |
lastElement()
|
int |
lastIndexOf(java.lang.Object elem)
|
int |
lastIndexOf(java.lang.Object elem,
int index)
|
java.lang.Object |
remove(int index)
|
boolean |
remove(java.lang.Object o)
|
boolean |
removeAll(java.util.Collection c)
|
void |
removeAllElements()
|
boolean |
removeElement(java.lang.Object obj)
|
void |
removeElementAt(int index)
|
protected void |
removeRange(int fromIndex,
int toIndex)
This really shouldn't be called, but for the sake of compatibility perform this function (it's slow though). |
boolean |
retainAll(java.util.Collection c)
|
java.lang.Object |
set(int index,
java.lang.Object element)
|
void |
setElementAt(java.lang.Object obj,
int index)
|
void |
setSize(int newSize)
|
int |
size()
|
java.util.List |
subList(int fromIndex,
int toIndex)
|
java.lang.Object[] |
toArray()
|
java.lang.Object[] |
toArray(java.lang.Object[] a)
|
void |
trimToSize()
If the decorated list is an instance of ArrayList ,
call trimToSize() on it. |
Methods inherited from class java.util.Vector |
---|
toString |
Methods inherited from class java.util.AbstractList |
---|
iterator, listIterator, listIterator |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
iterator, listIterator, listIterator |
Field Detail |
---|
public static final ICollectionFactory LIST_TO_VECTOR_ADAPTER_FACTORY
protected java.util.List _list
protected java.util.ArrayList _arrayList
_list
is an instance of ArrayList
,
this field is set to the casted version of _list
. This is
not final so that this instance can be cloned.
Constructor Detail |
---|
public ListToVectorAdapter()
ArrayList
.
public ListToVectorAdapter(int capacity)
ArrayList
.
public ListToVectorAdapter(java.util.Collection c)
c
. The
collection will be copied so that the user is free to modify
c
after construction.
public ListToVectorAdapter(java.util.Collection c, boolean copy)
c
. If
copy
is true or c
is not an instance of
RandomAccess
, the collection will be copied so that the
user is free to modify c
after construction.
Method Detail |
---|
public void add(int index, java.lang.Object element)
add
in interface java.util.List
add
in class java.util.Vector
public boolean add(java.lang.Object o)
add
in interface java.util.Collection
add
in interface java.util.List
add
in class java.util.Vector
public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
addAll
in interface java.util.List
addAll
in class java.util.Vector
public boolean addAll(int index, java.util.Collection c)
addAll
in interface java.util.List
addAll
in class java.util.Vector
public void addElement(java.lang.Object obj)
addElement
in class java.util.Vector
public int capacity()
List
or ArrayList
.
capacity
in class java.util.Vector
public void clear()
clear
in interface java.util.Collection
clear
in interface java.util.List
clear
in class java.util.Vector
public java.lang.Object clone()
clone
in class java.util.Vector
public boolean contains(java.lang.Object elem)
contains
in interface java.util.Collection
contains
in interface java.util.List
contains
in class java.util.Vector
public boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
containsAll
in interface java.util.List
containsAll
in class java.util.Vector
public void copyInto(java.lang.Object[] anArray)
copyInto
in class java.util.Vector
public java.lang.Object elementAt(int index)
elementAt
in class java.util.Vector
public java.util.Enumeration elements()
elements
in class java.util.Vector
public void ensureCapacity(int minCapacity)
ArrayList
,
call ensureCapacity()
on it. Otherwise, do nothing.
ensureCapacity
in class java.util.Vector
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection
equals
in interface java.util.List
equals
in class java.util.Vector
public java.lang.Object firstElement()
firstElement
in class java.util.Vector
public java.lang.Object get(int index)
get
in interface java.util.List
get
in class java.util.Vector
public int hashCode()
hashCode
in interface java.util.Collection
hashCode
in interface java.util.List
hashCode
in class java.util.Vector
public int indexOf(java.lang.Object elem)
indexOf
in interface java.util.List
indexOf
in class java.util.Vector
public int indexOf(java.lang.Object elem, int index)
indexOf
in class java.util.Vector
public void insertElementAt(java.lang.Object obj, int index)
insertElementAt
in class java.util.Vector
public boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in interface java.util.List
isEmpty
in class java.util.Vector
public java.lang.Object lastElement()
lastElement
in class java.util.Vector
public int lastIndexOf(java.lang.Object elem)
lastIndexOf
in interface java.util.List
lastIndexOf
in class java.util.Vector
public int lastIndexOf(java.lang.Object elem, int index)
lastIndexOf
in class java.util.Vector
public java.lang.Object remove(int index)
remove
in interface java.util.List
remove
in class java.util.Vector
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection
remove
in interface java.util.List
remove
in class java.util.Vector
public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
removeAll
in interface java.util.List
removeAll
in class java.util.Vector
public void removeAllElements()
removeAllElements
in class java.util.Vector
public boolean removeElement(java.lang.Object obj)
removeElement
in class java.util.Vector
public void removeElementAt(int index)
removeElementAt
in class java.util.Vector
protected void removeRange(int fromIndex, int toIndex)
fromIndex
equals toIndex
, do nothing.
removeRange
in class java.util.Vector
java.lang.IndexOutOfBoundsException
- if toIndex
is greater
than the size of this vector.
java.lang.IllegalArgumentException
- if fromIndex
is greater
than toIndex
.public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
retainAll
in interface java.util.List
retainAll
in class java.util.Vector
public java.lang.Object set(int index, java.lang.Object element)
set
in interface java.util.List
set
in class java.util.Vector
public void setElementAt(java.lang.Object obj, int index)
setElementAt
in class java.util.Vector
public void setSize(int newSize)
setSize
in class java.util.Vector
public int size()
size
in interface java.util.Collection
size
in interface java.util.List
size
in class java.util.Vector
public java.util.List subList(int fromIndex, int toIndex)
subList
in interface java.util.List
subList
in class java.util.Vector
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in class java.util.Vector
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in class java.util.Vector
public void trimToSize()
ArrayList
,
call trimToSize()
on it. Otherwise, do nothing.
trimToSize
in class java.util.Vector
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |