Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValOrderedVector<T>

Alternative interface: no Standard C++ Library

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

Synopsis

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

Please Note!


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


Description

RWTValOrderedVector<T> is an 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:

Note that an ordered vector has a length (the number of items returned by length() or entries()) and a capacity. Necessarily, the capacity is always greater than or equal to the length. Although elements beyond the collection's length are not used, nevertheless, in a value-based collection, they are occupied. If each instance of class T requires considerable resources, then you should ensure that the collection's capacity is not much greater than its length, otherwise unnecessary resources will be tied up.

Persistence

Isomorphic

Example

#include <rw/tvordvec.h>
#include <rw/rstream.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

Public Constructor

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

Public Operators

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

Public Member Functions

void
append(const T& a);
T&
at(size_t i);
const T&
at(size_t i) const;
void
clear();
RWBoolean
contains(const T& a) const;
const T*
data() const;
size_t
entries() const;
RWBoolean
find(const T& target, T& ret) const;
T&
first();
const T&
first() const;
size_t
index(const T& a) const;
void
insert(const T& a);
void
insertAt(size_t i, const T& a);
RWBoolean
isEmpty() const;
T&
last();
const T&
last() const;
size_t
length() const;
size_t
occurrencesOf(const T& a) const;
void
prepend(const T& a);
RWBoolean
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 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
Return to the main class reference
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.