java.lang.Object | +--org.apache.commons.collections.list.AbstractLinkedList | +--org.apache.commons.collections.list.NodeCachingLinkedListAll Implemented Interfaces:
transient int | The size of the cache. |
static int | The default value for #maximumCacheSize. |
transient AbstractLinkedList.Node | The first cached node, or null if no nodes are cached. |
int | The maximum size of the cache. |
Constructor that creates. |
NodeCachingLinkedList(Collection coll) Constructor that copies the specified collection |
NodeCachingLinkedList(int maximumCacheSize) Constructor that species the maximum cache size. |
void | addNodeToCache(AbstractLinkedList.Node node) Adds a node to the cache, if the cache isn't full. |
createNode(Object value) Creates a new node, either by reusing one from the cache or creating a new one. | |
int | Gets the maximum size of the cache. |
Gets a node from the cache. | |
boolean | Checks whether the cache is full. |
void | Removes all the nodes from the list, storing as many as required in the cache for reuse. |
void | removeNode(AbstractLinkedList.Node node) Removes the node from the list, storing it in the cache for reuse if the cache is not yet full. |
void | setMaximumCacheSize(int maximumCacheSize) Sets the maximum size of the cache. |
void | Reduce the size of the cache to the maximum, if necessary. |
protected transient int cacheSize
protected static final int DEFAULT_MAXIMUM_CACHE_SIZE
protected transient AbstractLinkedList.Node firstCachedNode
null
if no nodes are cached.
Cached nodes are stored in a singly-linked list with
next
pointing to the next element.
protected int maximumCacheSize
public NodeCachingLinkedList()
public NodeCachingLinkedList(Collection coll)
public NodeCachingLinkedList(int maximumCacheSize)
protected void addNodeToCache(AbstractLinkedList.Node node)
protected AbstractLinkedList.Node createNode(Object value)
protected int getMaximumCacheSize()
protected AbstractLinkedList.Node getNodeFromCache()
null
values for next, previous and element.
protected boolean isCacheFull()
protected void removeAllNodes()
protected void removeNode(AbstractLinkedList.Node node)
protected void setMaximumCacheSize(int maximumCacheSize)
protected void shrinkCacheToMaximumSize()
List
implementation that stores a cache of internal Node objects in an effort to reduce wasteful object creation. A linked list creates one Node for each item of data added. This can result in a lot of object creation and garbage collection. This implementation seeks to avoid that by maintaining a store of cached nodes. This implementation is suitable for long-lived lists where both add and remove are used. Short-lived lists, or lists which only grow will have worse performance using this class. Note that this implementation is not synchronized.