Class FixedSizeQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- org.apache.synapse.commons.executors.queues.FixedSizeQueue<E>
-
- Type Parameters:
E
- Should implement the Importance interface
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Queue<E>
,InternalQueue<E>
public class FixedSizeQueue<E> extends AbstractQueue<E> implements InternalQueue<E>
A bounded queue implementation for internal queues. This queue is backed by an fixed size array.
-
-
Constructor Summary
Constructors Constructor Description FixedSizeQueue(int priority, int capacity)
Create a queue with the given priority and capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Object o)
int
drainTo(Collection<? super E> c)
Drain items from this queue to the specified collectionint
drainTo(Collection<? super E> c, int maxElements)
Drain items from this queue to the specified collectionint
getCapacity()
Return the capacity of the queueCondition
getNotFullCond()
Get not full conditionint
getPriority()
Get the Priority of the queueIterator<E>
iterator()
boolean
offer(E e)
E
peek()
E
poll()
int
remainingCapacity()
Remaining capacity of the queue.boolean
remove(Object o)
void
setNotFullCond(Condition notFullCond)
Get not full conditionvoid
setPriority(int p)
Set the priorityint
size()
String
toString()
-
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Method Detail
-
getPriority
public int getPriority()
Description copied from interface:InternalQueue
Get the Priority of the queue- Specified by:
getPriority
in interfaceInternalQueue<E>
- Returns:
- priority
-
setPriority
public void setPriority(int p)
Description copied from interface:InternalQueue
Set the priority- Specified by:
setPriority
in interfaceInternalQueue<E>
- Parameters:
p
- priority
-
getNotFullCond
public Condition getNotFullCond()
Description copied from interface:InternalQueue
Get not full condition- Specified by:
getNotFullCond
in interfaceInternalQueue<E>
- Returns:
- not full condition
-
setNotFullCond
public void setNotFullCond(Condition notFullCond)
Description copied from interface:InternalQueue
Get not full condition- Specified by:
setNotFullCond
in interfaceInternalQueue<E>
- Parameters:
notFullCond
- condition
-
iterator
public Iterator<E> iterator()
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<E>
-
remainingCapacity
public int remainingCapacity()
Description copied from interface:InternalQueue
Remaining capacity of the queue. Unbounded queues should return Integer.MAX_VALUE- Specified by:
remainingCapacity
in interfaceInternalQueue<E>
- Returns:
- remaining capacity
-
drainTo
public int drainTo(Collection<? super E> c)
Description copied from interface:InternalQueue
Drain items from this queue to the specified collection- Specified by:
drainTo
in interfaceInternalQueue<E>
- Parameters:
c
- collection to add item- Returns:
- number of items added
-
drainTo
public int drainTo(Collection<? super E> c, int maxElements)
Description copied from interface:InternalQueue
Drain items from this queue to the specified collection- Specified by:
drainTo
in interfaceInternalQueue<E>
- Parameters:
c
- collection to add itemmaxElements
- maximum number of element to drain- Returns:
- number of items added
-
getCapacity
public int getCapacity()
Description copied from interface:InternalQueue
Return the capacity of the queue- Specified by:
getCapacity
in interfaceInternalQueue<E>
- Returns:
- capacity of thr queue
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<E>
- Overrides:
contains
in classAbstractCollection<E>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<E>
- Overrides:
remove
in classAbstractCollection<E>
-
-