org.jgroups.util
Class BoundedList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by java.util.concurrent.ConcurrentLinkedQueue<T>
              extended by org.jgroups.util.BoundedList<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Queue<T>

public class BoundedList<T>
extends java.util.concurrent.ConcurrentLinkedQueue<T>

A bounded subclass of LinkedList, oldest elements are removed once max capacity is exceeded. Note that this class is not synchronized (like LinkedList).

Author:
Bela Ban Nov 20, 2003
See Also:
Serialized Form

Constructor Summary
BoundedList()
           
BoundedList(int size)
           
 
Method Summary
 boolean add(T obj)
          Adds an element at the tail.
 boolean addIfAbsent(T obj)
           
 T removeFromHead()
           
 
Methods inherited from class java.util.concurrent.ConcurrentLinkedQueue
contains, isEmpty, iterator, offer, peek, poll, remove, size, toArray, toArray
 
Methods inherited from class java.util.AbstractQueue
addAll, clear, element, remove
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, removeAll, retainAll
 

Constructor Detail

BoundedList

public BoundedList()

BoundedList

public BoundedList(int size)
Method Detail

add

public boolean add(T obj)
Adds an element at the tail. Removes an object from the head if capacity is exceeded

Specified by:
add in interface java.util.Collection<T>
Specified by:
add in interface java.util.Queue<T>
Overrides:
add in class java.util.concurrent.ConcurrentLinkedQueue<T>
Parameters:
obj - The object to be added

addIfAbsent

public boolean addIfAbsent(T obj)

removeFromHead

public T removeFromHead()


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.