org.openbp.common.util
Class SizeRestrictedQueue

java.lang.Object
  extended by org.openbp.common.util.SizeRestrictedQueue

public class SizeRestrictedQueue
extends java.lang.Object

This class implements a queue that is restricted in size. If too much objects are queued in, the oldest values get disposed.

Author:
Falk Hartmann

Constructor Summary
SizeRestrictedQueue(int maxSize)
          This is the constructor.
 
Method Summary
 boolean contains(java.lang.Object obj)
          Checks if the queue contains the given element.
 void enqueue(java.lang.Object obj, boolean removeExisting)
          This method adds an element to a queue.
 void setDisposalListener(DisposalListener disposalListener)
          This method sets a disposal listener which gets called when an element gets removed from the queue.
 int size()
          Gets the current size of the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SizeRestrictedQueue

public SizeRestrictedQueue(int maxSize)
This is the constructor.

Parameters:
maxSize - The maximum size of the queue
Method Detail

size

public int size()
Gets the current size of the queue.


enqueue

public void enqueue(java.lang.Object obj,
                    boolean removeExisting)
This method adds an element to a queue.

Parameters:
obj - The object to be enqueued
removeExisting - true If the queue already contains the object, the object will be moved to the begin of the queue.
false Adds the object regardless if it is already present in the queue.

contains

public boolean contains(java.lang.Object obj)
Checks if the queue contains the given element.


setDisposalListener

public void setDisposalListener(DisposalListener disposalListener)
This method sets a disposal listener which gets called when an element gets removed from the queue.

Parameters:
disposalListener - The disposal listener


Copyright © 2011. All Rights Reserved.