Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTPtrOrderedVector<T>

Alternative interface: no Standard C++ Library

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

Synopsis

#include <rw/tpordvec.h>
RWTPtrOrderedVector<T> ordvec;

Please Note!


If you do not have the Standard C++ Library, use the interface described here. Otherwise, use the interface to RWTPtrOrderedVector described in the Class Reference.


Description

RWTPtrOrderedVector<T> is a pointer-based ordered collection. That is, the items in the collection have a meaningful ordered relationship with respect to one another and can be accessed by an index number. The order is set by the order of insertion. Duplicates are allowed. The class is implemented as a vector, allowing efficient insertion and retrieval from the end of the collection, but somewhat slower from the beginning of the collection.

The class T must have:

Persistence

Isomorphic

Example

#include <rw/tpordvec.h>
#include <rw/rstream.h>

main() {
  RWTPtrOrderedVector<double> vec;

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

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

  vec.clearAndDestroy();
  return 0;
}

Program output:

5 entries
22
5.3
-102.5
15
5.3

Public Constructors

RWTPtrOrderedVector<T>(size_t capac=RWDEFAULT_CAPACITY);
RWTPtrOrderedVector<T>(const RWTPtrOrderedVector<T>& c);

Public Operators

RWTPtrOrderedVector<T>&
operator=(const RWTPtrOrderedVector& c);
T*&
operator()(size_t i);
T* const&
operator()(size_t i) const;
T*&
operator[](size_t i);
T* const&
operator[](size_t i) const;

Public Member Functions

void
append(T* a);
T*&
at(size_t i);
T* const&
at(size_t i) const;
void
clear();
void
clearAndDestroy();
RWBoolean
contains(const T* a) const;
T* const *
data() const;
size_t
entries() const;
T*
find(const T* target) const;
T*&
first();
T* const&
first() const;
size_t
index(const T* a) const;
void
insert(T* a);
void
insertAt(size_t i, T* a);
RWBoolean
isEmpty() const;
T*&
last();
T* const&
last() const;
size_t
length() const;
size_t
occurrencesOf(const T* a) const;
void
prepend(T* a);
T*
remove(const T* a);
size_t
removeAll(const T* a);
T*
removeAt(size_t i);
T*
removeFirst();
T*
removeLast();
void
resize(size_t N);

Related Global Operators

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


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