17#ifndef _DECAF_UTIL_STLQUEUE_H_
18#define _DECAF_UTIL_STLQUEUE_H_
71 class QueueIterator :
public Iterator<T> {
74 typename std::list<T>::iterator current;
75 typename std::list<T>::iterator previous;
76 typename std::list<T>* queue;
80 QueueIterator(
typename std::list<T>* queue ) :
81 current( queue->begin() ), previous( queue->end() ), queue( queue ) {
84 virtual ~QueueIterator() {}
87 if( this->current == queue->end() ) {
90 "Queue::Iterator::next - No more elements to return" );
93 this->previous = this->current;
94 return *( this->current++ );
97 virtual bool hasNext()
const {
98 return ( this->current != queue->end() );
101 virtual void remove() {
102 if( this->previous == queue->end() ) {
105 "Queue::Iterator::remove - Invalid State to call remove" );
108 this->queue->erase( this->previous );
109 this->previous = this->queue->end();
124 return new QueueIterator( &queue );
139 if( queue.empty() ) {
143 return queue.front();
151 if( queue.empty() ) {
155 return queue.front();
163 if( queue.empty() ) {
175 if( queue.empty() ) {
187 queue.push_back( t );
195 queue.push_front( t );
203 if( queue.empty() ) {
209 T temp = queue.front();
228 return queue.empty();
235 std::vector<T> valueArray( queue.begin(), queue.end() );
246 target.queue.insert( target.queue.end(), queue.rbegin(), queue.rend() );
267 virtual void wait(
long long millisecs ) {
268 mutex.
wait( millisecs );
271 virtual void wait(
long long millisecs,
int nanos ) {
272 mutex.
wait( millisecs, nanos );
Definition IllegalStateException.h:32
Defines an object that can be used to iterate over the elements of a collection.
Definition Iterator.h:34
Definition NoSuchElementException.h:31
The Queue class accepts messages with an psuh(m) command where m is the message to be queued.
Definition StlQueue.h:60
size_t size() const
Gets the Number of elements currently in the Queue.
Definition StlQueue.h:219
virtual void wait(long long millisecs, int nanos)
Waits on a signal from this object, which is generated by a call to Notify.
Definition StlQueue.h:271
const T & back() const
Returns a Reference to the element at the tail of the queue.
Definition StlQueue.h:174
void enqueueFront(const T &t)
Places a new Object at the front of the queue.
Definition StlQueue.h:194
virtual void lock()
Locks the object.
Definition StlQueue.h:251
virtual ~StlQueue()
Definition StlQueue.h:117
bool empty() const
Checks if this Queue is currently empty.
Definition StlQueue.h:227
Iterator< T > * iterator()
Gets an Iterator over this Queue.
Definition StlQueue.h:123
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition StlQueue.h:263
virtual void unlock()
Unlocks the object.
Definition StlQueue.h:259
StlQueue()
Definition StlQueue.h:115
const T & front() const
Returns a Reference to the element at the head of the queue.
Definition StlQueue.h:150
T & back()
Returns a Reference to the element at the tail of the queue.
Definition StlQueue.h:162
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition StlQueue.h:279
virtual std::vector< T > toArray() const
Definition StlQueue.h:234
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
Definition StlQueue.h:255
virtual void wait(long long millisecs)
Waits on a signal from this object, which is generated by a call to Notify.
Definition StlQueue.h:267
T pop()
Removes and returns the element that is at the Head of the queue.
Definition StlQueue.h:202
void clear()
Empties this queue.
Definition StlQueue.h:130
void push(const T &t)
Places a new Object at the Tail of the queue.
Definition StlQueue.h:186
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition StlQueue.h:275
void reverse(StlQueue< T > &target) const
Reverses the order of the contents of this queue and stores them in the target queue.
Definition StlQueue.h:245
T & front()
Returns a Reference to the element at the head of the queue.
Definition StlQueue.h:138
T & getSafeValue()
Fetch a reference to the safe value this object will return when there is nothing to fetch from the q...
Definition StlQueue.h:290
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition Mutex.h:39
virtual void lock()
Locks the object.
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
virtual void unlock()
Unlocks the object.
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
The interface for all synchronizable objects (that is, objects that can be locked and unlocked).
Definition Synchronizable.h:37
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25