Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTPtrDeque<T>

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/tpdeque.h> 
RWTPtrDeque<T> deq;

Please Note!


RWTPtrDeque requires the Standard C++ Library.


Description

This class maintains a pointer-based collection of values, implemented as a double-ended queue, or deque. Class T is the type pointed to by the items in the collection.

Persistence

Isomorphic

Example

In this example, a double-ended queue of ints is exercised.

// tpdeque.cpp
#include <rw/tpdeque.h>
#include <iostream.h>
/* 
 * This program partitions integers into even and odd numbers
 */
int main(){
  RWTPtrDeque<int> numbers;
  int n;
  cout << "Input an assortment of integers (EOF to end):" 
       << endl;
  while (cin >> n) {
    if (n % 2 == 0) 
      numbers.pushFront(new int(n));
    else
      numbers.pushBack(new int(n));
  }
  while (numbers.entries()) {
    cout << *numbers.first() << endl;
    delete numbers.popFront();
  }
  return 0;
}
Program Input:
1 2 3 4 5
<eof>
Program Output:
4
2
1
3
5

Related Classes

Classes RWTPtrDlist<T>, RWTPtrSlist<T>, and RWTPtrOrderedVector<T> also provide a Rogue Wave pointer-based interface to C++-standard sequence collections.

Class deque<T*, allocator> is the C++-standard collection that serves as the underlying implementation for this class.

Public Typedefs

typedef deque<T*, allocator>                   container_type;
typedef container_type::iterator               iterator;
typedef container_type::const_iterator         const_iterator;
typedef container_type::size_type              size_type;
typedef container_type::difference_type        difference_type;
typedef T*                                     value_type;
typedef T*&                                    reference; 
typedef T* const&                              const_reference;

Public Constructors

RWTPtrDeque<T>();
RWTPtrDeque<T>(const deque<T*, allocator>& deq); 
RWTPtrDeque<T>(const RWTPtrDeque<T>& rwdeq);
RWTPtrDeque<T>(size_type n, T* a);
RWTPtrDeque<T>(T* const* first, T* const* last);

Public Member Operators

RWTPtrDeque<T>&
operator=(const RWTPtrDeque<T>& deq);
RWTPtrDeque<T>&
operator=(const deque<T*, allocator>& stddeq);
bool
operator<(const RWTPtrDeque<T>& deq);
bool
operator==(const RWTPtrDeque<T>& deq);
reference
operator()(size_type i) ;
const_reference
operator()(size_type i) const;
reference
operator[](size_type i); 
const_reference
operator[](size_type i) const;

Public Member Functions

void
append(T* a); 
void
apply(void (*fn)(T*,void*), void* d); 
void
apply(void (*fn)(const T*,void*), void* d) const; 
void
apply(void (*fn)(T*&,void*), void* d);
reference
at(size_type i); 
const_reference
at(size_type i) const;
iterator
begin();
const_iterator
begin() const;
void
clear();
void
clearAndDestroy();
bool
contains (const T* a) const; 
bool
contains (bool (*fn)(const T*, void*), void *d) const;
bool
contains(bool (*fn)(T*,void*), void* d) const;
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
T*
find(const T* a) const; 
T*
find(bool (*fn)( T*,void*), void* d) const;
T*
find(bool (*fn)(const T*,void*), void* d) const;
reference
first();
const_reference
first() const;
size_type
index(const T* a) const; 
size_type
index(bool (*fn)(T*,void*), void* d) const;
size_type
index(bool (*fn)(const T*,void*), void* d) const;
bool
insert(T* a); 
void
insertAt(size_type i, T* a); 
bool
isEmpty() const; 
T*&
last();
T* const &
last() const;
reference
maxElement();
const_reference
maxElement() const;
reference
minElement();
const_reference
minElement() const;
size_type
occurrencesOf(const T* a) const; 
size_type
occurrencesOf(bool (*fn)(T*,void*), void* d) const;
size_type
occurrencesOf(bool (*fn)(const T*,void*), void* d) const;
T*
popBack();
T*
popFront();
void
prepend(T* a); 
void
pushBack(T* a); 
void
pushFront(T* a); 
T*
remove(const T* a); 
T*
remove(bool (*fn)(T*, void*), void* d);
T*
remove(bool (*fn)(const T*,void*), void* d);
size_type const T*
removeAll(const_reference a); 
size_type
removeAll(bool (*fn)(T*,void*), void* d);
size_type
removeAll(bool (*fn)(const T*,void*), void* d);
T*
removeAt(size_type i); 
T*
removeFirst();
T*
removeLast();
size_type
replaceAll(const T* oldVal, T* newVal); 
size_type
replaceAll(bool (*fn)(T*, void*), void* x, T* newVal);
size_type
replaceAll(bool (*fn)(const T*, void*), void* x,
           const T* newVal);
void
sort();
deque<T*, allocator>&
std();
const deque<T*, allocator>&
std() const;

Static Public Data Member

size_type  npos;

Related Global Operators

RWvostream&
operator<<(RWvostream& strm, const RWTPtrDeque<T>& coll);
RWFile&
operator<<(RWFile& strm, const RWTPtrDeque<T>& coll);
RWvistream&
operator>>(RWvistream& strm, RWTPtrDeque<T>& coll);
RWFile&
operator>>(RWFile& strm, RWTPtrDeque<T>& coll);
RWvistream&
operator>>(RWvistream& strm, RWTPtrDeque<T>*& p);
RWFile&
operator>>(RWFile& strm, RWTPtrDeque<T>*& p);


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.