Package org.wso2.carbon.queuing
Interface CarbonQueue<T>
-
- Type Parameters:
T- the type of objects stored in this queue.
public interface CarbonQueue<T>represents a generic queue that can be used by the carbon platform.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Method to clear this queue.Tget(int index)Method to retrieve the element at the given index of this queue.intindexOf(T element)This method returns the index of the given element on this queue.booleanisEmpty()Method to test whether this queue is empty.Tpeek()Retrieves, but does not remove, the head of this queue.List<T>peek(int count)Retrieves, but does not remove, the given number of items from the top, which also includes the head of this queue.Tpop()Retrieves and removes, the head of this queue.List<T>pop(int count)Retrieves and removes, the given number of items from the top, which also includes the head of this queue.voidpush(List<T> elements)Adds the given elements onto the queue.voidpush(T element)Adds the given element onto the queue.intsize()Method to obtain the size of this queue.
-
-
-
Method Detail
-
peek
T peek() throws QueueEmptyException
Retrieves, but does not remove, the head of this queue.- Returns:
- the head of this queue.
- Throws:
QueueEmptyException- when this queue is empty.
-
peek
List<T> peek(int count) throws QueueEmptyException
Retrieves, but does not remove, the given number of items from the top, which also includes the head of this queue.- Parameters:
count- the number of items to return.- Returns:
- the given number of items from the top, which also includes the head of this queue
- Throws:
QueueEmptyException- when this queue is empty.
-
pop
T pop() throws QueueEmptyException
Retrieves and removes, the head of this queue.- Returns:
- the head of this queue.
- Throws:
QueueEmptyException- when this queue is empty.
-
pop
List<T> pop(int count) throws QueueEmptyException
Retrieves and removes, the given number of items from the top, which also includes the head of this queue.- Parameters:
count- the number of items to return.- Returns:
- the given number of items from the top, which also includes the head of this queue.
- Throws:
QueueEmptyException- when this queue is empty.
-
push
void push(T element)
Adds the given element onto the queue.- Parameters:
element- the element to add.
-
push
void push(List<T> elements)
Adds the given elements onto the queue.- Parameters:
elements- the elements to add.
-
size
int size()
Method to obtain the size of this queue.- Returns:
- the size of this queue.
-
isEmpty
boolean isEmpty()
Method to test whether this queue is empty.- Returns:
- true if the queue is empty or false if not.
-
clear
void clear()
Method to clear this queue.
-
indexOf
int indexOf(T element) throws QueueEmptyException
This method returns the index of the given element on this queue.- Parameters:
element- the element.- Returns:
- the index of the given element.
- Throws:
QueueEmptyException- when this queue is empty.
-
get
T get(int index)
Method to retrieve the element at the given index of this queue.- Parameters:
index- the index of the element.- Returns:
- the element.
-
-