|
JIDE Common Layer 2.7.6 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.Vector<E>
com.jidesoft.utils.CachedVector<E>
public class CachedVector<E>
This is a fast access Vector that sacrifices memory for speed. It will reduce the speed of indexOf method from O(n) to O(1). However it will at least double the memory used by Vector. So use it appropriately.
Just like
Vector, this implementation is synchronized. Incomparisonn, CachedArrayList
is not synchronized.
Field Summary |
---|
Fields inherited from class java.util.Vector |
---|
capacityIncrement, elementCount, elementData |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
CachedVector()
|
|
CachedVector(java.util.Collection<? extends E> c)
|
|
CachedVector(int initialCapacity)
|
Method Summary | |
---|---|
boolean |
add(E element)
|
void |
add(int index,
E element)
|
boolean |
addAll(java.util.Collection<? extends E> c)
|
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
|
protected void |
adjustCache(int index,
int increase)
Adjusts the cache so that all values that are greater than index will increase by the value specified by the increase parameter. |
void |
cacheAll()
Cache all the element index. |
void |
cacheIt(java.lang.Object o,
int index)
Caches the index of the element. |
void |
clear()
|
protected java.util.Map<java.lang.Object,java.lang.Integer> |
createCache()
|
int |
indexOf(java.lang.Object elem)
|
void |
invalidateCache()
Invalidated the whole cache. |
boolean |
isLazyCaching()
|
E |
remove(int index)
|
boolean |
remove(java.lang.Object o)
|
boolean |
removeAll(java.util.Collection<?> c)
|
protected void |
removeRange(int fromIndex,
int toIndex)
|
E |
set(int index,
E element)
|
void |
setLazyCaching(boolean lazyCaching)
|
void |
uncacheAll()
Uncache the whole cache. |
void |
uncacheIt(java.lang.Object o)
Uncaches the index of the element. |
Methods inherited from class java.util.Vector |
---|
addElement, capacity, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, removeAllElements, removeElement, removeElementAt, retainAll, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CachedVector()
public CachedVector(java.util.Collection<? extends E> c)
public CachedVector(int initialCapacity)
Method Detail |
---|
public int indexOf(java.lang.Object elem)
indexOf
in interface java.util.List<E>
indexOf
in class java.util.Vector<E>
protected void adjustCache(int index, int increase)
index
- the index. All values above this index will be changed.increase
- a positive number to increase or a negative number to decrease.protected java.util.Map<java.lang.Object,java.lang.Integer> createCache()
public void cacheIt(java.lang.Object o, int index)
o
- the elementindex
- the index.public void uncacheIt(java.lang.Object o)
o
- the elementpublic boolean add(E element)
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in class java.util.Vector<E>
public void add(int index, E element)
add
in interface java.util.List<E>
add
in class java.util.Vector<E>
public E remove(int index)
remove
in interface java.util.List<E>
remove
in class java.util.Vector<E>
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
remove
in interface java.util.List<E>
remove
in class java.util.Vector<E>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.List<E>
removeAll
in class java.util.Vector<E>
public void clear()
clear
in interface java.util.Collection<E>
clear
in interface java.util.List<E>
clear
in class java.util.Vector<E>
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
addAll
in class java.util.Vector<E>
public boolean addAll(int index, java.util.Collection<? extends E> c)
addAll
in interface java.util.List<E>
addAll
in class java.util.Vector<E>
public E set(int index, E element)
set
in interface java.util.List<E>
set
in class java.util.Vector<E>
public void invalidateCache()
public void uncacheAll()
invalidateCache()
.
public void cacheAll()
public boolean isLazyCaching()
public void setLazyCaching(boolean lazyCaching)
protected void removeRange(int fromIndex, int toIndex)
removeRange
in class java.util.Vector<E>
|
JIDE Common Layer 2.7.6 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |