Package moa.core
Class FixedLengthList<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<E>
-
- moa.core.FixedLengthList<E>
-
- Type Parameters:
E
- the type of object found in the FixedLengthList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
public class FixedLengthList<E> extends ArrayList<E>
FixedLengthList is an extension of an ArrayList with a fixed maximum size. If an element is added that would put the list over its maximum size then the oldest element in the list is removed.- Author:
- Richard Hugh Moulton
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description FixedLengthList(int m)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E entry)
Calls super.add(entry) to append the entry to the end of the FixedLengthList.boolean
addAll(Collection<? extends E> c)
Appends all of the elements in the argument collection in the order that they are returned by the collection's iterator.int
getMaxSize()
E
getOldestEntry()
E
getYoungestEntry()
-
Methods inherited from class java.util.ArrayList
add, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Method Detail
-
add
public boolean add(E entry)
Calls super.add(entry) to append the entry to the end of the FixedLengthList. Removes the oldest entry if required. Returns true at completion.
-
addAll
public boolean addAll(Collection<? extends E> c)
Appends all of the elements in the argument collection in the order that they are returned by the collection's iterator. Does so by calling FixedLengthList.add(E entry).
-
getOldestEntry
public E getOldestEntry()
- Returns:
- the least recently added object in the list.
-
getYoungestEntry
public E getYoungestEntry()
- Returns:
- the most recently added object in the list.
-
getMaxSize
public int getMaxSize()
- Returns:
- the size limit of the FixedLengthList.
-
-