SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTQueue< T, C > Class Template Reference

A queue of templatized objects that supports user-specified containers. More...

#include <rw/tqueue.h>

Public Member Functions

 RWTQueue ()
 
 RWTQueue (C &&rhs)
 
 RWTQueue (const C &rhs)
 
 RWTQueue (const RWTQueue &rhs)
 
 RWTQueue (RWTQueue &&rhs)
 
void clear ()
 
size_t entries () const
 
first () const
 
get ()
 
void insert (const T &a)
 
void insert (T &&a)
 
bool isEmpty () const
 
last () const
 
RWTQueueoperator= (const RWTQueue &rhs)
 
RWTQueueoperator= (RWTQueue &&rhs)
 
void swap (RWTQueue< T, C > &rhs)
 

Detailed Description

template<class T, class C>
class RWTQueue< T, C >

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:

  • well-defined copy semantics (T::T(const T&) or equivalent)
  • well-defined assignment semantics (T::operator=(const T&) or equivalent)
  • any other semantics required by class C.

Parameter C represents the class used for implementation. The class C must provide the following interface (or equivalent):

  • void C::append(const T&)
  • void C::clear()
  • size_t C::entries() const
  • T C::first()
  • bool C::isEmpty() const
  • T C::last()
  • T C::removeFirst()
  • a default constructor (C::C())
  • a copy constructor (C::C(const C&))
  • an assignment operator (C& C::operator=(const C&))

These methods must behave in a manner that is consistent with that of RWTValDlist for this class to function as intended.

Useful choices for C are RWTValSlist or RWTValDlist. Vectors, such as RWTValOrderedVector, can also be used, but tend to be less efficient at removing an object from the front of the queue.

Synopsis
#include <rw/tqueue.h>
A queue of templatized objects that supports user-specified containers.
Definition tqueue.h:101
Persistence
None
Example
#include <rw/cstring.h>
#include <rw/tqueue.h>
#include <rw/tvslist.h>
#include <iostream>
int main() {
q.insert("one"); // Type conversion occurs
q.insert("two");
q.insert("three");
while (!q.isEmpty()) {
std::cout << q.get() << std::endl;
}
return 0;
}
void insert(const T &a)
Definition tqueue.h:192
T get()
Definition tqueue.h:181
bool isEmpty() const
Definition tqueue.h:187

Program output

one
two
three

Constructor & Destructor Documentation

◆ RWTQueue() [1/5]

template<class T , class C >
RWTQueue< T, C >::RWTQueue ( )
inline

Constructs a queue.

◆ RWTQueue() [2/5]

template<class T , class C >
RWTQueue< T, C >::RWTQueue ( const C & rhs)
inlineexplicit

Constructs a queue from the container rhs.

◆ RWTQueue() [3/5]

template<class T , class C >
RWTQueue< T, C >::RWTQueue ( const RWTQueue< T, C > & rhs)
inline

Copy constructor. Constructs self as a copy of rhs.

◆ RWTQueue() [4/5]

template<class T , class C >
RWTQueue< T, C >::RWTQueue ( C && rhs)
inlineexplicit

Move constructor. Takes ownership of the data owned by rhs.

Condition:
This method is available only on platforms with rvalue reference support.

◆ RWTQueue() [5/5]

template<class T , class C >
RWTQueue< T, C >::RWTQueue ( RWTQueue< T, C > && rhs)
inline

Move constructor. Takes ownership of the data owned by rhs.

Condition:
This method is available only on platforms with rvalue reference support.

Member Function Documentation

◆ clear()

template<class T , class C >
void RWTQueue< T, C >::clear ( )
inline

Calls C::clear() on the underlying container.

◆ entries()

template<class T , class C >
size_t RWTQueue< T, C >::entries ( ) const
inline

Returns the result of calling C::entries() on the underlying container.

◆ first()

template<class T , class C >
T RWTQueue< T, C >::first ( ) const
inline

Returns the result of calling C::first() on the underlying container.

◆ get()

template<class T , class C >
T RWTQueue< T, C >::get ( )
inline

Returns the result of calling C::removeFirst() on the underlying container.

◆ insert() [1/2]

template<class T , class C >
void RWTQueue< T, C >::insert ( const T & a)
inline

Calls C::append(a) on the underlying container.

◆ insert() [2/2]

template<class T , class C >
void RWTQueue< T, C >::insert ( T && a)
inline

Calls C::append(a) on the underlying container.

Condition:
This method is available only on platforms with rvalue reference support.

◆ isEmpty()

template<class T , class C >
bool RWTQueue< T, C >::isEmpty ( ) const
inline

Returns the result of calling C::isEmpty() on the underlying container.

◆ last()

template<class T , class C >
T RWTQueue< T, C >::last ( ) const
inline

Returns the result of calling C::last() on the underlying container.

◆ operator=() [1/2]

template<class T , class C >
RWTQueue & RWTQueue< T, C >::operator= ( const RWTQueue< T, C > & rhs)
inline

Assignment operator. Sets self to a copy of rhs.

◆ operator=() [2/2]

template<class T , class C >
RWTQueue & RWTQueue< T, C >::operator= ( RWTQueue< T, C > && rhs)
inline

Move assignment. Takes ownership of the data owned by rhs.

Condition:
This method is available only on platforms with rvalue reference support.

◆ swap()

template<class T , class C >
void RWTQueue< T, C >::swap ( RWTQueue< T, C > & rhs)
inline

Swaps the data owned by self with the data owned by rhs.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.