Package org.drools.core.util
Class TreeSetQueue<T extends Queue.QueueEntry>
- java.lang.Object
-
- org.drools.core.util.TreeSetQueue<T>
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,Queue<T>
public class TreeSetQueue<T extends Queue.QueueEntry> extends java.lang.Object implements Queue<T>, java.io.Externalizable
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.drools.core.util.Queue
Queue.QueueEntry
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
log
-
Constructor Summary
Constructors Constructor Description TreeSetQueue()
TreeSetQueue(java.util.Comparator<T> comparator)
Constructs a newBinaryHeap
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears all elements from queue.T
dequeue()
Returns the Queueable on top of heap and remove it.void
dequeue(T activation)
void
enqueue(T element)
Inserts an Queueable into queue.java.util.Collection<T>
getAll()
boolean
isEmpty()
Tests if queue is empty.T
peek()
void
readExternal(java.io.ObjectInput in)
int
size()
Returns the number of elements in this heap.java.lang.String
toString()
void
writeExternal(java.io.ObjectOutput out)
-
-
-
Constructor Detail
-
TreeSetQueue
public TreeSetQueue()
-
TreeSetQueue
public TreeSetQueue(java.util.Comparator<T> comparator)
Constructs a newBinaryHeap
.- Parameters:
comparator
- the comparator used to order the elements, null means use natural order
-
-
Method Detail
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
clear
public void clear()
Clears all elements from queue.- Specified by:
clear
in interfaceQueue<T extends Queue.QueueEntry>
-
getAll
public java.util.Collection<T> getAll()
- Specified by:
getAll
in interfaceQueue<T extends Queue.QueueEntry>
-
isEmpty
public boolean isEmpty()
Tests if queue is empty.- Specified by:
isEmpty
in interfaceQueue<T extends Queue.QueueEntry>
- Returns:
true
if queue is empty;false
otherwise.
-
size
public int size()
Returns the number of elements in this heap.- Specified by:
size
in interfaceQueue<T extends Queue.QueueEntry>
- Returns:
- the number of elements in this heap
-
peek
public T peek()
- Specified by:
peek
in interfaceQueue<T extends Queue.QueueEntry>
-
enqueue
public void enqueue(T element)
Inserts an Queueable into queue.- Specified by:
enqueue
in interfaceQueue<T extends Queue.QueueEntry>
- Parameters:
element
- the Queueable to be inserted
-
dequeue
public T dequeue()
Returns the Queueable on top of heap and remove it.- Specified by:
dequeue
in interfaceQueue<T extends Queue.QueueEntry>
- Returns:
- the Queueable at top of heap
-
dequeue
public void dequeue(T activation)
- Specified by:
dequeue
in interfaceQueue<T extends Queue.QueueEntry>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-