Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValDeque<T>

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

Synopsis

#include <rw/tvdeque.h> 
RWTValDeque<T> deq;

Standard C++ Library Dependent!


RWTValDeque requires the Standard C++ Library.


Description

This class maintains a collection of values implemented as a double-ended queue, or deque. Order is determined externally and elements are accessible by index. Use this class when insertions and deletions usually occur at either the beginning or the end of the collection.

Persistence

Isomorphic

Example

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

//
// tvdqint.cpp
//
#include <rw/tvdeque.h>
#include <iostream.h>

/* 
 * This program partitions integers into even and odd numbers
 */

int main(){
  RWTValDeque<int> numbers;

  int n;
  
  cout << "Input an assortment of integers (EOF to end):" 
       << endl;
  
  while (cin >> n) {
    if (n % 2 == 0) 
      numbers.pushFront(n);
    else
      numbers.pushBack(n);
  }

  while (numbers.entries()) {
    cout << numbers.popFront() << endl;
  }
      
  return 0;
}

Program Input:
1 2 3 4 5
<eof>

Program Output:
4
2
1
3
5

Related Classes

Classes RWTValSlist<T>, RWTValDlist<T>, RWTValSortedDlist<T>, and RWTValOrderedVector<T> also provide a Rogue Wave interface to C++-standard sequence collections. The list classes should be considered for frequent insertions (or removals) in the interior of the collection. The vector may be more efficient if most insertions and removals occur at the end of the collection.

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 T                                   value_type; 
typedef T&                                  reference; 
typedef const T&                            const_reference; 

Public Constructors

RWTValDeque<T>();
RWTValDeque<T>(const deque<T,allocator>& deq); 
RWTValDeque<T>(const RWTValDeque<T>& rwdeq);
RWTValDeque<T>(size_type n, const T& val = T());
RWTValDeque<T>(const T* first, const T* last);

Public Member Operators

RWTValDeque<T>&
operator=(const RWTValDeque<T,allocator>& deq); 
RWTValDeque<T>&
operator=(const deque<T>& deq);
bool
operator<(const RWTValDeque<T>& deq) const; 
bool
operator<(const deque<T,allocator>& deq) const;
bool
operator==(const RWTValDeque<T>& deq) const; 
bool
operator==(const deque<T,allocator>& deq) const;
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(const_reference a); 
void
apply(void (*fn)(reference,void*), void* d); 
void
apply(void (*fn)(const_reference,void*), void* d) const;
reference
at(size_type i); 
const_reference
at(size_type i) const;
iterator
begin();
const_iterator
begin() const;
void
clear();
bool
contains(const_reference a) const; 
bool
contains(bool (*fn)(const_reference,void*), void* d) const;
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
bool
find(const_reference a,T& k) const; 
bool
find(bool (*fn)(const_reference,void*), void* d, T& k) const; 
reference
first();
const_reference
first() const;
size_type
index(const_reference a) const; 
size_type
index(bool (*fn)(const_reference,void*), void* d) const;
bool
insert(const_reference a); 
void
insertAt(size_type i, const_reference a); 
bool
isEmpty() const; 
reference
last();
const_reference
last() const;
reference
maxElement();
const_reference
maxElement() const;
reference
minElement();
const_reference
minElement() const;
size_type 
occurrencesOf(const_reference a) const; 
size_type
occurrencesOf(bool (*fn)(const_reference,void*),void* d) const;
void
prepend(const_reference a); 
T
popBack();
T
popFront();
void
pushBack(const_reference a); 
void
pushFront(const_reference a); 
bool
remove(const_reference a); 
bool
remove(bool (*fn)(const_reference,void*), void* d);
size_type
removeAll(const_reference a); 
size_type
removeAll(bool (*fn)(const_reference,void*), void* d);
T
removeAt(size_type i); 
T
removeFirst();
T
removeLast();
size_type
replaceAll(const T& oldVal, const T& newVal); 
size_type
replaceAll(bool (*fn)(const T&,void*), void* d, 
       const T& newVal);
void
sort();
deque<T,allocator>&
std();
const deque<T,allocator>&
std() const;

Static Public Data Member

const size_type  npos;

Related Global Operators

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


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