Package com.opencloud.sentinel.multileg
Interface MessageQueue<T>
-
- Type Parameters:
T-
- All Superinterfaces:
java.lang.Iterable<T>
- All Known Subinterfaces:
SipMessageQueue
public interface MessageQueue<T> extends java.lang.Iterable<T>Interface for message queue.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanadd(T e)Adds an elementto the end of the queue. voidaddFirst(T e)Add an elementto the start of the queue. voidclear()Removes all of the elementsfrom this queue. Telement()Retrieves, but does not remove, the head of this queue.booleanisEmpty()Determines if queue is empty.booleanoffer(T e)Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.Tpeek()Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. TpeekLast()Retrieves, but does not remove, the last element of this queue, or returns nullif this queue is empty.Tpoll()Retrieves and removes the head of this queue, or returns null if this queue is empty.Tremove()Retrieves and removes the head of this queue.intsize()Returns the number of elements in this collection.
-
-
-
Method Detail
-
add
boolean add(T e)
Adds an elementto the end of the queue. - Parameters:
e- the element to add, notnull.- Throws:
java.lang.NullPointerException- if the specified element is null
-
offer
boolean offer(T e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable toadd(T), which can fail to insert an element only by throwing an exception.- Parameters:
e- the element to add- Returns:
- true if the element was added to this queue, else false
- Throws:
java.lang.ClassCastException- if the class of the specified element prevents it from being added to this queuejava.lang.NullPointerException- if the specified element is null and this queue does not permit null elementsjava.lang.IllegalArgumentException- if some property of this element prevents it from being added to this queue
-
peek
T peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. - Returns:
- head of queue, or null if empty queue.
-
addFirst
void addFirst(T e)
Add an elementto the start of the queue. - Parameters:
e- the message to add, notnull.- Throws:
java.lang.NullPointerException- if the specified element is null
-
peekLast
T peekLast()
Retrieves, but does not remove, the last element of this queue, or returns nullif this queue is empty.- Returns:
- last element of queue, or
nullif empty queue.
-
clear
void clear()
Removes all of the elementsfrom this queue.
-
isEmpty
boolean isEmpty()
Determines if queue is empty.- Returns:
trueif queue is empty.
-
remove
T remove()
Retrieves and removes the head of this queue. This method differs frompollonly in that it throws an exception if this queue is empty.- Returns:
- the head of this queue
- Throws:
java.util.NoSuchElementException- if this queue is empty
-
poll
T poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.- Returns:
- the head of this queue, or null if this queue is empty
-
element
T element()
Retrieves, but does not remove, the head of this queue. This method differs frompeekonly in that it throws an exception if this queue is empty.- Returns:
- the head of this queue
- Throws:
java.util.NoSuchElementException- if this queue is empty
-
size
int size()
Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.- Returns:
- the number of elements in this collection
-
-