private final class LifecycleExtensionManager.CachedArrayList
extends java.lang.Object
CachedArrayList class.
This class wraps a synchronized ArrayList to provide an optimized
toArray() method that returns an internally cached array,
rather than a new array generated per toArray()
invocation.
Use of the class by the Manager results in toArray()
being invoked far more often than any other method. Caching the value
toArray normally returns is intended to be a performance
optimization.
The cached array value is updated upon each write operation to the List.
REVISIT(MC): investigate using FastArrayList from collections ?
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Object[] |
EMPTY_ARRAY |
private java.lang.Object[] |
m_cache |
private java.util.List |
m_proxy |
| Modifier | Constructor and Description |
|---|---|
private |
LifecycleExtensionManager.CachedArrayList() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.Object object)
Add an object to the list
|
void |
clear()
Clear the list
|
void |
copyFrom(LifecycleExtensionManager.CachedArrayList original)
Become a copy of another CachedArrayList.
|
java.lang.Object |
get(int index)
Access an object that is in the list
|
int |
indexOf(java.lang.Object object)
Find out the index of an object in the list
|
void |
insert(int position,
java.lang.Object object)
Insert an object into a particular position in the list
|
java.util.Iterator |
iterator()
Obtain an iterator.
|
java.lang.Object |
remove(int position)
Remove an object from the list
|
int |
size()
Obtain the size of the list
|
java.lang.Object[] |
toArray()
Obtain the list as an array.
|
private final java.lang.Object[] EMPTY_ARRAY
private final java.util.List m_proxy
private java.lang.Object[] m_cache
private LifecycleExtensionManager.CachedArrayList()
public void copyFrom(LifecycleExtensionManager.CachedArrayList original)
public void add(java.lang.Object object)
object - an Object valuepublic void insert(int position,
java.lang.Object object)
position - an int valueobject - an Object valuepublic java.lang.Object remove(int position)
position - an int valueObject valuepublic java.util.Iterator iterator()
Iterator valuepublic int size()
int valuepublic java.lang.Object get(int index)
index - an int valueObject valuepublic int indexOf(java.lang.Object object)
object - an Object valueint valuepublic void clear()
public java.lang.Object[] toArray()
Object[] value