org.omnaest.utils.structure.collection.list
Class LimitedLinkedList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<E>
                  extended by 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

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LimitedLinkedList()
           
LimitedLinkedList(Collection<? extends E> collection)
           
LimitedLinkedList(Collection<? extends E> collection, int sizeMax)
           
LimitedLinkedList(int sizeMax)
           
 
Method Summary
 boolean add(E e)
           
 void add(int index, E element)
           
 boolean addAll(Collection<? extends E> c)
           
 boolean addAll(int index, Collection<? extends E> c)
           
 void addFirst(E e)
           
 void addLast(E e)
           
 int getSizeMax()
          Returns the maximum size threshold
 boolean isRemoveFirstElementByExceedingSize()
           
 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().
 void setSizeMax(int sizeMax)
          Sets the maximum size the LimitedLinkedList can have.
 
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
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 
Methods inherited from interface java.util.Deque
iterator
 

Constructor Detail

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)
Method Detail

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.