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 boolean
add(T e)
Adds an elementto the end of the queue. void
addFirst(T e)
Add an elementto the start of the queue. void
clear()
Removes all of the elementsfrom this queue. T
element()
Retrieves, but does not remove, the head of this queue.boolean
isEmpty()
Determines if queue is empty.boolean
offer(T e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.T
peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. T
peekLast()
Retrieves, but does not remove, the last element of this queue, or returns null
if this queue is empty.T
poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.T
remove()
Retrieves and removes the head of this queue.int
size()
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 null
if this queue is empty.- Returns:
- last element of queue, or
null
if empty queue.
-
clear
void clear()
Removes all of the elementsfrom this queue.
-
isEmpty
boolean isEmpty()
Determines if queue is empty.- Returns:
true
if queue is empty.
-
remove
T remove()
Retrieves and removes the head of this queue. This method differs frompoll
only 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 frompeek
only 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
-
-