org.omnaest.utils.structure.collection.list
Class LimitedLinkedList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<E>
org.omnaest.utils.structure.collection.list.LimitedLinkedList<E>
- Type Parameters:
E -
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>
public class LimitedLinkedList<E>
- extends LinkedList<E>
Size limited Queue which can be configured to ignore further adding of elements if the size limit is reached, or to
dump the oldest entry.
- Author:
- Omnaest
- See Also:
setRemoveFirstElementByExceedingSize(boolean),
Serialized Form
| Methods inherited from class java.util.LinkedList |
clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray |
LimitedLinkedList
public LimitedLinkedList(Collection<? extends E> collection,
int sizeMax)
- Parameters:
collection - sizeMax -
LimitedLinkedList
public LimitedLinkedList(int sizeMax)
- Parameters:
sizeMax -
LimitedLinkedList
public LimitedLinkedList()
- See Also:
setSizeMax(int)
LimitedLinkedList
public LimitedLinkedList(Collection<? extends E> collection)
- Parameters:
collection - - See Also:
setSizeMax(int)
addFirst
public void addFirst(E e)
- Specified by:
addFirst in interface Deque<E>- Overrides:
addFirst in class LinkedList<E>
addLast
public void addLast(E e)
- Specified by:
addLast in interface Deque<E>- Overrides:
addLast in class LinkedList<E>
add
public boolean add(E e)
- Specified by:
add in interface Collection<E>- Specified by:
add in interface Deque<E>- Specified by:
add in interface List<E>- Specified by:
add in interface Queue<E>- Overrides:
add in class LinkedList<E>
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll in interface Collection<E>- Specified by:
addAll in interface List<E>- Overrides:
addAll in class LinkedList<E>
addAll
public boolean addAll(int index,
Collection<? extends E> c)
- Specified by:
addAll in interface List<E>- Overrides:
addAll in class LinkedList<E>
add
public void add(int index,
E element)
- Specified by:
add in interface List<E>- Overrides:
add in class LinkedList<E>
setSizeMax
public void setSizeMax(int sizeMax)
- Sets the maximum size the
LimitedLinkedList can have.
- Parameters:
sizeMax -
getSizeMax
public int getSizeMax()
- Returns the maximum size threshold
- Returns:
isRemoveFirstElementByExceedingSize
public boolean isRemoveFirstElementByExceedingSize()
- Returns:
- See Also:
setRemoveFirstElementByExceedingSize(boolean)
setRemoveFirstElementByExceedingSize
public void setRemoveFirstElementByExceedingSize(boolean removeFirstElementByExceedingSize)
- If set to true always the
LinkedList.removeFirst() is called as long as the LinkedList.size() exceeds the getSizeMax()
otherwise the LinkedList.removeLast(). Default is true.
- Parameters:
removeFirstElementByExceedingSize -
Copyright © 2013. All Rights Reserved.