SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A queue of templatized objects that supports user-specified containers. More...
#include <rw/tqueue.h>
Public Member Functions | |
RWTQueue () | |
RWTQueue (const RWTQueue &rhs) | |
RWTQueue (RWTQueue &&rhs) | |
RWTQueue & | operator= (const RWTQueue &rhs) |
RWTQueue & | operator= (RWTQueue &&rhs) |
void | clear () |
size_t | entries () const |
T | first () const |
T | get () |
bool | isEmpty () const |
void | insert (const T &a) |
void | insert (T &&a) |
T | last () const |
void | swap (RWTQueue< T, C > &rhs) |
Class RWTQueue represents a parameterized queue. Not only can the type of object inserted into the queue be parameterized, but also the implementation.
Parameter T
represents the type of object in the queue, either a class or built-in type. The class T
must have:
T::T(const T&
) or equivalent)T::operator=(const T&)
or equivalent)C
.Parameter C
represents the class used for implementation. Useful choices are RWTValSlist<T,A> or RWTValDlist<T,A>. Vectors, such as RWTValOrderedVector<T,A>, can also be used, but tend to be less efficient at removing an object from the front of the list.
#include <rw/tqueue.h> RWTQueue<T, C> queue;
None
#include <iostream> #include <rw/tqueue.h> #include <rw/cstring.h> #include <rw/tvslist.h> int main() { RWTQueue<RWCString, RWTValSlist<RWCString> > q; q.insert("one"); // Type conversion occurs q.insert("two"); q.insert("three"); while (!q.isEmpty()) std::cout << q.get() << std::endl; return 0; }
Program output
one two three
Copy constructor. Constructs self as a copy of rhs.
Move constructor. Takes ownership of the data owned by rhs.
void RWTQueue< T, C >::clear | ( | void | ) | [inline] |
Removes all items from the queue.
size_t RWTQueue< T, C >::entries | ( | void | ) | const [inline] |
Returns the number of items in the queue.
T RWTQueue< T, C >::first | ( | void | ) | const [inline] |
Returns, but does not remove, the first item in the queue (the earliest item inserted into the queue).
T RWTQueue< T, C >::get | ( | void | ) | [inline] |
Returns and removes the first item in the queue (the earliest item inserted into the queue).
void RWTQueue< T, C >::insert | ( | T && | a | ) | [inline] |
Inserts the item a at the end of the queue.
void RWTQueue< T, C >::insert | ( | const T & | a | ) | [inline] |
Inserts the item a at the end of the queue.
bool RWTQueue< T, C >::isEmpty | ( | ) | const [inline] |
Returns true
if there are no items in the queue, otherwise false
.
T RWTQueue< T, C >::last | ( | void | ) | const [inline] |
Returns, but does not remove, the last item in the queue (the item most recently inserted into the queue).
RWTQueue& RWTQueue< T, C >::operator= | ( | RWTQueue< T, C > && | rhs | ) | [inline] |
Move assignment. Takes ownership of the data owned by rhs.
RWTQueue& RWTQueue< T, C >::operator= | ( | const RWTQueue< T, C > & | rhs | ) | [inline] |
Assignment operator. Sets self to a copy of rhs.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.