Package org.ldaptive.pool
Class Queue<T>
- java.lang.Object
-
- org.ldaptive.pool.Queue<T>
-
- Type Parameters:
T
- type of object in the queue
- All Implemented Interfaces:
java.lang.Iterable<T>
public class Queue<T> extends java.lang.Object implements java.lang.Iterable<T>
Provides a wrapper around aDeque
to support LIFO and FIFO operations.- Author:
- Middleware Services
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T t)
Adds an object to the queue based on the queue type.boolean
contains(T t)
Returns whether t is in the queue.T
element()
Retrieves, but does not remove, the first element in the queue.boolean
isEmpty()
Returns whether or not the queue is empty.java.util.Iterator<T>
iterator()
T
remove()
Removes the first element in the queue.boolean
remove(T t)
Removes the supplied element from the queue.int
size()
Returns the number of elements in the queue.java.lang.String
toString()
-
-
-
Constructor Detail
-
Queue
public Queue(QueueType type)
Creates a new queue.- Parameters:
type
- how will objects be inserted into the queue
-
-
Method Detail
-
add
public void add(T t)
Adds an object to the queue based on the queue type. SeeDeque.offerFirst(Object)
andDeque.offerLast(Object)
.- Parameters:
t
- to add
-
remove
public T remove()
Removes the first element in the queue. SeeDeque.removeFirst()
.- Returns:
- first element in the queue
-
remove
public boolean remove(T t)
Removes the supplied element from the queue. SeeDeque.remove(Object)
.- Parameters:
t
- to remove- Returns:
- whether t was removed
-
element
public T element()
Retrieves, but does not remove, the first element in the queue. SeeDeque.getFirst()
.- Returns:
- first element in the queue
-
contains
public boolean contains(T t)
Returns whether t is in the queue. SeeDeque.contains(Object)
.- Parameters:
t
- that may be in the queue- Returns:
- whether t is in the queue
-
isEmpty
public boolean isEmpty()
Returns whether or not the queue is empty. SeeCollection.isEmpty()
}.- Returns:
- whether the queue is empty
-
size
public int size()
Returns the number of elements in the queue. SeeDeque.size()
.- Returns:
- number of elements in the queue
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-