org.quartz.utils
Class CircularLossyQueue<T>

java.lang.Object
  extended by org.quartz.utils.CircularLossyQueue<T>
Type Parameters:
T - Type of the item's to add in this queue

public class CircularLossyQueue<T>
extends Object

An implementation of a CircularQueue data-structure. When the number of items added exceeds the maximum capacity, items that were added first are lost.

Since:
1.7
Author:
Abhishek Sanoujam

Constructor Summary
CircularLossyQueue(int size)
          Constructs the circular queue with the specified capacity
 
Method Summary
 int depth()
          Returns the number of items currently in the queue
 boolean isEmtpy()
          Returns true if the queue is empty, otherwise false
 T peek()
          Returns value at the tail of the queue
 void push(T newVal)
          Adds a new item
 T[] toArray(T[] type)
          Returns an array of the current elements in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CircularLossyQueue

public CircularLossyQueue(int size)
Constructs the circular queue with the specified capacity

Parameters:
size -
Method Detail

push

public void push(T newVal)
Adds a new item

Parameters:
newVal -

toArray

public T[] toArray(T[] type)
Returns an array of the current elements in the queue. The order of elements is in reverse order of the order items were added.

Parameters:
type -
Returns:
An array containing the current elements in the queue. The first element of the array is the tail of the queue and the last element is the head of the queue

peek

public T peek()
Returns value at the tail of the queue

Returns:
Value at the tail of the queue

isEmtpy

public boolean isEmtpy()
Returns true if the queue is empty, otherwise false

Returns:
true if the queue is empty, false otherwise

depth

public int depth()
Returns the number of items currently in the queue

Returns:
the number of items in the queue


Copyright 2001-2019, Terracotta, Inc.