Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide

RWTPtrSortedVector<T,C,A>

Module:  Essential Tools Module   Group:  STL-based Collection


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/tpsrtvec.h> 
RWTPtrSortedVector<T,C,A> srtvec;

Description

This class maintains an always-sorted pointer-based collection of values, implemented as a vector. Items are ordered according to a comparison object of type C. Class T is the type pointed to by the items in the collection. C must induce a total ordering on elements of type T via a public member

which returns TRUE if x should precede y within the collection. The structure less<T> from the C++-standard header file <functional> is an example. Note that items in the collection will be dereferenced before being compared.

The value type must have operator== and operator< defined. This requirement is imposed by the Standard C++ Library.

Persistence

Isomorphic

Example

In this example, a sorted vector of RWDates is exercised.

Program Output:

Related Classes

RWTPtrSortedDlist<T,C,A> is an alternative always-sorted pointer-based collection. RWTPtrOrderedVector<T,A> is an unsorted pointer-based vector.

Class vector<T*,A<T*> > is the Standard C++ Library collection that serves as the underlying implementation for this class.

Public Typedefs

typedef vector<T*,A> container_type; 
typedef rw_deref_compare<C,T> container_comp; 
typedef typename container_type::const_iterator
  const_iterator;
typedef typename container_type::const_iterator iterator; 
typedef typename container_type::size_type size_type;
typedef typename container_type::difference_type
  difference_type;
typedef T* value_type; 
typedef T*& reference; 
typedef T* const& const_reference; 

Public Constructors

RWTPtrSortedVector<T,C,A>();
RWTPtrSortedVector<T,C,A> (const vector<T*,A<T*> >& vec); 
RWTPtrSortedVector<T,C,A> 
  (const RWTPtrSortedVector<T,C,A> & rwvec);
RWTPtrSortedVector<T,C,A> (size_type n, T* p);
RWTPtrSortedVector<T,C,A> (size_type n);
RWTPtrSortedVector<T,C,A> (T** first,T** last);

Public Member Operators

bool
operator<(const RWTPtrSortedVector<T,C,A> & vec) const; 
bool
operator==(const RWTPtrSortedVector<T,C,A> & vec) 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
apply(void (*fn)(T*,void*), void* d); 
void
apply(void (*fn)(T*&,void*), void* d);
void
apply(void (*fn)(const T*,void*), void* d) const;
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;
T* const*
data() const; 
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
const T*
find(const T* a) const; 
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)(const T*,void*), void* d) const;
bool
insert(T* a); 
size_type
insert(const vector<T*,A>& a);
bool
isEmpty() const; 
bool
isSorted() const; 
T*&
last();
T* const&
last() const;
size_type
length() const; 
size_type
merge(const RWTPtrSortedVector<T,C,A> & vec);
size_type
occurrencesOf(const T* a) const; 
size_type
occurrencesOf(bool (*fn)(const T*,void*), void* d) const;
T*
remove(const T* a); 
T*
remove(bool (*fn)(const T*,void*), void* d); 
size_type
removeAll(const T* a);
size_type
removeAll(bool (*fn)(const T*,void*), void* d); 
T*
removeAt(size_type i); 
T*
removeFirst();
T*
removeLast();
void
resize(size_type n); 
const vector<T*,A<T*> >&
std() const; 

Related Global Operators

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


Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, 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.