Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValOrderedVector<T>

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

Synopsis

#include <rw/tvordvec.h> 
RWTValOrderedVector<T> ordvec;

Please Note!


If you have the Standard C++ Library, use the interface described here. Otherwise, use the restricted interface to RWTValOrderedVector described in Appendix A.


Description

This class maintains a collection of values, implemented as a vector.

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 vector of type double is exercised.

//
// tvordvec.cpp
//
#include <rw/tvordvec.h>
#include <iostream.h>

main() {
  RWTValOrderedVector<double> vec;

  vec.insert(22.0);
  vec.insert(5.3);
  vec.insert(-102.5);
  vec.insert(15.0);
  vec.insert(5.3);

  cout << vec.entries() << " entries\n" << endl;  // Prints "5"
  for (int i=0; i<vec.length(); i++)
    cout << vec[i] << endl;

  return 0;
}
Program Output:
5 entries

22
5.3
-102.5
15
5.3

Related Classes

Classes RWTValDeque<T>, RWTValSlist<T>, and RWTValDlist<T> also provide a Rogue Wave interface to C++-standard sequence collections.

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

Public Typedefs

typedef vector<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

RWTValOrderedVector<T>();
RWTValOrderedVector<T>(const vector<T,allocator>& vec);
RWTValOrderedVector<T>(const RWTValOrderedVector<T>& rwvec);
RWTValOrderedVector<T>(size_type n, const T& val);
RWTValOrderedVector<T>(size_type n);
RWTValOrderedVector<T>(const T* first, const T* last);

Public Member Operators

RWTValOrderedVector<T>&
operator=(const RWTValOrderedVector<T>& vec); 
RWTValOrderedVector<T>&
operator=(const vector<T,allocator>& vec);
bool
operator<(const RWTValOrderedVector<T>& vec); 
bool
operator<(const vector<T>& vec);
bool
operator==(const RWTValOrderedVector<T>& vec) const; 
bool
operator==(const vector<T>& vec) const;
T&
operator()(size_type i); 
const T&
operator()(size_type i) const;
T&
operator[](size_type i); 
const T&
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;
const T*
data() const; 
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
bool
find(const_reference a, value_type& k) const; 
bool
find(bool (*fn)(const_reference,void*), void* d, 
     value_type& 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;
size_type
length() 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); 
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);
value_type
removeAt(size_type i); 
value_type
removeFirst();
value_type
removeLast();
size_type
replaceAll(const_reference oldVal, const_reference newVal); 
size_type
replaceAll(bool (*fn)(const_reference,void*), 
           void* d, const T& newval); 
void
resize(size_type n); 
void
sort();
vector<T,allocator>&
std();
const vector<T,allocator>&
std() const;

Static Public Data Member

const size_type  npos;

Related Global Operators

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


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