|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.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(Collection<? extends E> c)
|
|
CachedVector(int initialCapacity)
|
Method Summary | |
---|---|
boolean |
add(E element)
|
void |
add(int index,
E element)
|
boolean |
addAll(Collection<? extends E> c)
|
boolean |
addAll(int index,
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(Object o,
int index)
Caches the index of the element. |
void |
clear()
|
protected Map<Object,Integer> |
createCache()
|
int |
indexOf(Object elem)
|
void |
invalidateCache()
Invalidated the whole cache. |
boolean |
isLazyCaching()
|
E |
remove(int index)
|
boolean |
remove(Object o)
|
boolean |
removeAll(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(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, lastElement, lastIndexOf, lastIndexOf, removeAllElements, removeElement, removeElementAt, retainAll, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize |
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 |
Constructor Detail |
---|
public CachedVector()
public CachedVector(Collection<? extends E> c)
public CachedVector(int initialCapacity)
Method Detail |
---|
public int indexOf(Object elem)
indexOf
in interface List<E>
indexOf
in class 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 Map<Object,Integer> createCache()
public void cacheIt(Object o, int index)
o
- the elementindex
- the index.public void uncacheIt(Object o)
o
- the elementpublic boolean add(E element)
add
in interface Collection<E>
add
in interface List<E>
add
in class Vector<E>
public void add(int index, E element)
add
in interface List<E>
add
in class Vector<E>
public E remove(int index)
remove
in interface List<E>
remove
in class Vector<E>
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface List<E>
remove
in class Vector<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
removeAll
in interface List<E>
removeAll
in class Vector<E>
public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
clear
in class Vector<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class Vector<E>
public boolean addAll(int index, Collection<? extends E> c)
addAll
in interface List<E>
addAll
in class Vector<E>
public E set(int index, E element)
set
in interface List<E>
set
in class 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 Vector<E>
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |