|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.cau.cs.kieler.sim.kiem.config.data.MostRecentCollection<T>
T
- The type of the items contained in the list.public class MostRecentCollection<T>
This implements a collection that can update according to most recent use. New items will be added at index 0 and all items already in it will be pushed down. The oldest item may be deleted if the list is already at capacity.
If an item is added that is already in the list it will be moved to the top of the list.
Removing an item from the list has the same behavior as in a normal linked list.
Constructor Summary | |
---|---|
MostRecentCollection()
Creates a new list with default capacity 10. |
|
MostRecentCollection(int newCapacity)
Create a new list. |
|
MostRecentCollection(List<T> list)
Creates a new handler for a given list. |
|
MostRecentCollection(List<T> list,
int capacityParam)
Creates a new handler for a given list with a maximum capacity. |
Method Summary | ||
---|---|---|
boolean |
add(T e)
Add a new item to the head of the list. |
|
boolean |
addAll(Collection<? extends T> c)
|
|
void |
clear()
|
|
MostRecentCollection<T> |
clone()
Create a copy of this object, using a shallow copy. |
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
T |
get(int index)
Get the element at the specified index. |
|
boolean |
isEmpty()
|
|
Iterator<T> |
iterator()
|
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
void |
replace(T oldElement,
T newElement)
Replaces the given element with the new one. |
|
boolean |
retainAll(Collection<?> c)
|
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(Type[] a)
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Constructor Detail |
---|
public MostRecentCollection()
public MostRecentCollection(int newCapacity)
newCapacity
- the maximum capacity of the list.public MostRecentCollection(List<T> list)
list
- the new listpublic MostRecentCollection(List<T> list, int capacityParam)
list
- the new listcapacityParam
- the maximum capacity of the listMethod Detail |
---|
public boolean add(T e)
Add a new item to the head of the list.
If the list already contains the new item it will be moved to the head and the rest of the list pushed down.
add
in interface Collection<T>
e
- the new element
public boolean addAll(Collection<? extends T> c)
addAll
in interface Collection<T>
public void clear()
clear
in interface Collection<T>
public boolean contains(Object o)
contains
in interface Collection<T>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<T>
public T get(int index)
index
- index of the element to get.
public boolean isEmpty()
isEmpty
in interface Collection<T>
public Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
public boolean remove(Object o)
remove
in interface Collection<T>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<T>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<T>
public void replace(T oldElement, T newElement)
oldElement
- the element to be replacednewElement
- the replacement elementpublic int size()
size
in interface Collection<T>
public Object[] toArray()
toArray
in interface Collection<T>
public <Type> Type[] toArray(Type[] a)
toArray
in interface Collection<T>
public String toString()
toString
in class Object
public MostRecentCollection<T> clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |