|
Same level pages: Parent level pages: | The template class The STL queue template is found in <queue>. A simplified declaration of the queue template would look something like: template<class T> class queue { public: queue(); bool empty() const; unsigned size() const; T& top(); const T& top() const; void push(const T& x); void pop(); protected: deque<T> c; }; Note that top() is used instead of the front() to access the next element to be removed from the queue. Similarly, push(T) and pop() are used instead of enqueue(T) and dequeue(). In reality, the queue class is an adapter class that
can be implemented by containers other than the deque container. In particular
the
The full declaration of a queue looks something like: template<class T, class Cont = deque<T> > class queue { public: typedef Cont::allocator_type allocator_type; typedef Cont::value_type value_type; typedef Cont::size_type size_type; explicit queue(const allocator_type& al = allocator_type()) const; bool empty() const; size_type size() const; allocator_type get_allocator() const; value_type& top(); const value_type& top() const; void push(const value_type& x); void pop(); protected: Cont c; }; |
NOTICE: The information presented on this page represents the personal views, ideas, and opinions of the author. This is not an official Ball State University web page. Links contained at this web site to other organizations, are presented as a service and neither constitute nor imply university endorsement or warranty. |