RWGVector(3C++)

RWGVector(val) - Rogue Wave library class

As shipped in IRIX 6.5.5. Unchanged since IRIX 6.5.

Name
     RWGVector(val) - Rogue Wave library class

Synopsis
              #include <rw/gvector.h>



              declare(RWGVector,val)
          implement(RWGVector,val)
          RWGVector(val) a;   // A Vector of val's.




Description
     Class RWGVector(val) represents a group of ordered elements, accessible
     by an index.  Duplicates are allowed. This class is implemented as an
     array.  Objects of type RWGVector(val) are declared with macros defined
     in the standard C++ header file <generic.h>. Note that it is a value-
     based collection: items are copied in and out of the collection.  The
     class val must have:
          a default constructor;

          well-defined copy semantics (val::val(const val&) or equiv.);

          well-defined assignment semantics (val::operator=(const val&) or
          equivalent).


Persistence
     For each type of RWGVector, you must include one (and only one) call to
     the macro implement, somewhere in your code.  None

Example
              #include <rw/gvector.h>



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


              declare(RWGVector, RWDate)   /* Declare a vector of dates */



              implement(RWGVector, RWDate) /* Implement a vector of dates */

              main()  {



                RWGVector(RWDate) oneWeek(7);
            for (int i=1; i<7; i++)
              oneWeek(i) = oneWeek(0) + i;


                for (i=0; i<7; i++)



                  cout << oneWeek(i) << endl;



                return 0;



              }

     Program output:

              04/12/93
          04/13/93
          04/14/93
          04/15/93
          04/16/93
          04/17/93

Public Constructors
     04/18/93



              RWGVector(val)();


     Construct an empty vector.

              RWGVector(val)(size_t n);


     Construct a vector with length n. The initial values of the elements can
     (and probably will) be garbage.

              RWGVector(val)(size_t n, val v);


     Construct a vector with length n. Each element is assigned the value v.
              RWGVector(val)(RWGVector(val)& s);


     Copy constructor.  The entire vector is copied, including all embedded
     values.

Public Member Operators
              RWGVector(val)&
          operator=(RWGVector(val)& s);


     Assignment operator.  The entire vector is copied.

              RWGVector(val)&
          operator=(val v);


     Sets all elements of self to the value v.

              val
          operator()(size_t i) const;
          val&
          operator()(size_t i);


     Return the i'th element in the vector.  The index i must be between zero
     and the length of the vector less one.  No bounds checking is performed.
     The second variant can be used as an lvalue.

              val
          operator[](size_t i) const;
          val&
          operator[](size_t i);


     Return the ith element in the vector.  The index i must be between zero
     and the length of the vector less one.  Bounds checking is performed.

Public Member Functions
              const val*
          data() const;


     Returns a pointer to the raw data of self.  Should be used with care.

              size_t
          length() const;


     Returns the length of the vector.

              void
          reshape(size_t n);


     Resize the vector.  If the vector shrinks, it will be truncated.  If the
     vector grows, then the value of the additional elements will be
     undefined.