Contents

NAME
LANGUAGE
DESCRIPTION
SYNOPSYS
Inheritance and Namespace
Public members
Constructors
Miscellaneous
Assignment
Mutating
Initializing
SEE ALSO
AUTHOR
COPYRIGHT and LICENSE
Version
Downloading

rvector - A automatically resizing std::vector class.

C++

This C++ template class can be used to implement templated vectors. It resizes itself according to usage. This class implements several functions which will be described below.

rvector<T,Alloc> inherits from vector<T,Alloc>, so it can be used by functions that accept a templated std::vector class.

Classes that are used with the rvector class are required to implement the ''='' operator.

When a vector element at a position > len() is referenced, the vector is resized to this position. All Elements between the previous len() and the new len() are given a default value (from the T constructor, i.e., the constructor without required parameters (implicit parameters are allowed)).

Classes that are used with this vector class are required to implement the default constructor.

C++ exceptions are used to raise fatal errors. Thrown exceptions are of type std::string.

        #include <rvector>

        int main() 
        {
                std::rvector<int> A;
                int i,N;

                for(i=0;i<100;i++) {
                        A[i]=i*i;
                }

                for(i=0,N=A.len();i<N;i++) {
                        printf("%d*%d=%d\\n",i,i,A[i]);
                }

                return 0;
        }

std::rvector inherits from std::vector. It uses the same namespace: ''std''.

Initializes a new rvector<T> object.

Initializes a new rvector<T> object of size ''n''.

Initializes a new rvector<T> object of size ''n'' preinitialized to the value of ''e''.

Initializes a new rvector<T> object and copies all values of the given vector in it. NOTE: The type of the argument ''std::vector'' also catches objects of type ''std::rvector''.

Cleans up an rvector object and all of it''s vector members.

Swaps array element i with element j.

Returns the current actual length of the vector (not the reserved internal length or size).

Assigns all elements of the given vector (or rvector) to the current rvector object.

Inserts element ''e'' at location ''i'' of rvector, and resizes the internal vector as necessary.

Removes element at location ''i'' of the rvector.

Returns a reference to the element at location ''i'' of the rvector.

Sets the element at location ''i'' of the rvector to the value of ''e''.

Sets the element at location ''i'' of the rvector to the value of ''e''.

The documentation on std::vector at http://www.sgi.com/tech/stl.

Hans Oesterholt-Dijkema <hdnews -at- gawab.com>

(c) 2000 - 2004 Hans Oesterholt-Dijkema.
This header file has been release under Artistice License.

$Id: rvector.h,v 1.6 2004/07/19 12:08:45 cvs Exp $

Latest releases of all packages can be found here.

page hits: 1009, last edit: