站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

CachedList (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


org.jboss.util.collection
Class CachedList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byorg.jboss.util.collection.CachedList
All Implemented Interfaces:
Collection, List

public class CachedList
extends AbstractList

A wrapper around a List which translates added objects into SoftObject references, allowing the VM to garbage collect objects in the collection when memory is low.

Version:
$Revision: 1.3 $
Author:
Jason Dillon

Field Summary
protected  List list
          Wrapped list.
protected  ReferenceQueue queue
          Reference queue.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
CachedList()
          Construct a CachedList using a LinkedList for storage.
CachedList(List list)
          Construct a CachedList.
 
Method Summary
 void add(int index, Object obj)
          Inserts the specified element at the specified position in this list (optional operation).
 Object get(int index)
          Returns the element at the specified position in this list.
 Object remove(int index)
          Removes the element at the specified position in this list (optional operation).
 Object set(int index, Object obj)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Return the size of the list.
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

queue

protected final ReferenceQueue queue
Reference queue.


list

protected final List list
Wrapped list.

Constructor Detail

CachedList

public CachedList(List list)
Construct a CachedList.

Parameters:
list - List to wrap.

CachedList

public CachedList()
Construct a CachedList using a LinkedList for storage.

Method Detail

get

public Object get(int index)
Returns the element at the specified position in this list.

Parameters:
index - Index of element to return.
Returns:
The element at the specified position.

size

public int size()
Return the size of the list.

Returns:
The number of elements in the list.

set

public Object set(int index,
                  Object obj)
Replaces the element at the specified position in this list with the specified element.

Parameters:
index - Index of element to replace.
obj - Element to be stored at the specified postion.
Returns:
The previous element at the given index.

add

public void add(int index,
                Object obj)
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
index - Index at which the specified element is to be inserted.
obj - Element to be inserted.

remove

public Object remove(int index)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters:
index - The index of the element to remove.
Returns:
The element previously at the specified position.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.