rwlogo
SourcePro C++ 12.5

SourcePro® C++ API Reference Guide

Product Documentation:

   SourcePro C++
Documentation Home

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Public Types | Public Member Functions
RWTValVector< T > Class Template Reference

A value-based collection of values implemented as a vector. More...

#include <rw/tvvector.h>

Inherited by RWClassicTValOrderedVector< T > [private].

Public Types

typedef const_pointer const_iterator
 
typedef const value_typeconst_pointer
 
typedef const value_typeconst_reference
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 
typedef ptrdiff_t difference_type
 
typedef pointer iterator
 
typedef value_typepointer
 
typedef value_typereference
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 
typedef size_t size_type
 
typedef T value_type
 

Public Member Functions

 RWTValVector ()
 
 RWTValVector (size_type n)
 
 RWTValVector (size_type n, const_reference ival)
 
 RWTValVector (const RWTValVector< T > &rhs)
 
 RWTValVector (RWTValVector< T > &&rhs)
 
 ~RWTValVector ()
 
iterator begin ()
 
const_iterator begin () const
  More...
 
const_iterator cbegin () const
  More...
 
const_iterator cend () const
  More...
 
const_reverse_iterator crbegin () const
  More...
 
const_reverse_iterator crend () const
  More...
 
pointer data ()
 
const_pointer data () const
  More...
 
iterator end ()
 
const_iterator end () const
  More...
 
size_type length () const
 
reference operator() (size_type i)
 
const_reference operator() (size_type i) const
 
RWTValVector< T > & operator= (const RWTValVector< T > &rhs)
 
RWTValVector< T > & operator= (RWTValVector< T > &&rhs)
 
RWTValVector< T > & operator= (const_reference ival)
 
reference operator[] (size_type i)
 
const_reference operator[] (size_type i) const
  More...
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
  More...
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
  More...
 
void reshape (size_type N)
 
void swap (RWTValVector< T > &rhs)
 

Detailed Description

template<class T>
class RWTValVector< T >

Class RWTValVector<T> is a simple parameterized vector of objects of type T. It is most useful when you know precisely how many objects have to be held in the collection. If the intention is to "insert" an unknown number of objects, then class RWTValOrderedVector<T,A> may be a better choice.

The class T must have:

Synopsis

#include <rw/tvvector.h>

Persistence

Isomorphic

Example

//
// tvvector.cpp
//
#include <iostream>
#include <rw/tvvector.h>
#include <rw/tools/datetime.h>
int main ()
{
RWDateTime begin(RWDateTime::setCurrentTime); // Today's date
for (size_t i = 0; i < 7; ++i) {
begin.incrementDay(1);
week[i] = begin;
}
for (size_t i = 0; i < 7; ++i) {
std::cout << week[i].asString('x') << "\n";
}
return 0;
}

Program output (if this is run on June 19, 2009):

06/19/09
06/20/09
06/21/09
06/22/09
06/23/09
06/24/09
06/25/09

Member Typedef Documentation

template<class T>
typedef const_pointer RWTValVector< T >::const_iterator

A type that provides a const random-access iterator over the elements in the container.

template<class T>
typedef const value_type* RWTValVector< T >::const_pointer

A type that provides a const pointer to an element in the container.

template<class T>
typedef const value_type& RWTValVector< T >::const_reference

A type that provides a const reference to an element in the container.

template<class T>
typedef std::reverse_iterator<const_iterator> RWTValVector< T >::const_reverse_iterator

A type that provides a const random-access, reverse-order iterator over the elements in the container.

template<class T>
typedef ptrdiff_t RWTValVector< T >::difference_type

A signed integral type used to indicate the distance between two valid iterators on the same container.

template<class T>
typedef pointer RWTValVector< T >::iterator

A type that provides a random-access iterator over the elements in the container.

template<class T>
typedef value_type* RWTValVector< T >::pointer

A type that provides a pointer to an element in the container.

template<class T>
typedef value_type& RWTValVector< T >::reference

A type that provides a reference to an element in the container.

template<class T>
typedef std::reverse_iterator<iterator> RWTValVector< T >::reverse_iterator

A type that provides a random-access, reverse-order iterator over the elements in the container.

template<class T>
typedef size_t RWTValVector< T >::size_type

An unsigned integral type used for counting the number of elements in the container.

template<class T>
typedef T RWTValVector< T >::value_type

A type representing the container's data type.

Constructor & Destructor Documentation

template<class T>
RWTValVector< T >::RWTValVector ( )
inline

Constructs an empty vector of length zero.

template<class T>
RWTValVector< T >::RWTValVector ( size_type  n)
inline

Constructs a vector of length n. The values of the elements are set by the default constructor of class value_type.

template<class T>
RWTValVector< T >::RWTValVector ( size_type  n,
const_reference  ival 
)

Constructs a vector of length n, with each element initialized to the value ival.

template<class T>
RWTValVector< T >::RWTValVector ( const RWTValVector< T > &  rhs)

Constructs self as a copy of rhs. Each element in rhs is copied into self.

template<class T>
RWTValVector< T >::RWTValVector ( RWTValVector< T > &&  rhs)

Move constructor. The constructed vector takes ownership of the data owned by rhs.

Condition:
This method is only available on platforms with rvalue reference support.
template<class T>
RWTValVector< T >::~RWTValVector ( )
inline

Calls the destructor for every element in self.

Member Function Documentation

template<class T>
iterator RWTValVector< T >::begin ( )
inline

Returns an iterator referring to the first element in the container.

If the container is empty, returns end().

template<class T>
const_iterator RWTValVector< T >::begin ( ) const
inline

Returns an iterator referring to the first element in the container.

If the container is empty, returns end().

template<class T>
const_iterator RWTValVector< T >::cbegin ( ) const
inline

Returns an iterator referring to the first element in the container.

If the container is empty, returns end().

template<class T>
const_iterator RWTValVector< T >::cend ( ) const
inline

Returns an iterator referring to the element after the last element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

template<class T>
const_reverse_iterator RWTValVector< T >::crbegin ( ) const
inline

Returns an iterator referring to the last element in the container.

If the container is empty, returns rend().

template<class T>
const_reverse_iterator RWTValVector< T >::crend ( ) const
inline

Returns an iterator referring to the element before the first element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

template<class T>
pointer RWTValVector< T >::data ( void  )
inline

Returns a pointer to the first element of the vector. The value returned is undefined if the vector is empty.

template<class T>
const_pointer RWTValVector< T >::data ( void  ) const
inline

Returns a pointer to the first element of the vector. The value returned is undefined if the vector is empty.

template<class T>
iterator RWTValVector< T >::end ( )
inline

Returns an iterator referring to the element after the last element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

template<class T>
const_iterator RWTValVector< T >::end ( ) const
inline

Returns an iterator referring to the element after the last element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

template<class T>
size_type RWTValVector< T >::length ( ) const
inline

Returns the length of the vector.

template<class T>
reference RWTValVector< T >::operator() ( size_type  i)
inline

Returns a reference to the i th value in the vector. Index i should be between 0 and one less than the number of entries, otherwise the results are undefined.

Note
No bounds checking is performed.
template<class T>
const_reference RWTValVector< T >::operator() ( size_type  i) const
inline

Returns a reference to the i th value in the vector. Index i should be between 0 and one less than the number of entries, otherwise the results are undefined.

Note
No bounds checking is performed.
template<class T>
RWTValVector<T>& RWTValVector< T >::operator= ( const RWTValVector< T > &  rhs)

Sets self to the same length as rhs and then copies all elements of rhs into self.

template<class T>
RWTValVector<T>& RWTValVector< T >::operator= ( RWTValVector< T > &&  rhs)

Move assignment. Self takes ownership of the data owned by rhs.

Condition:
This method is only available on platforms with rvalue reference support.
template<class T>
RWTValVector<T>& RWTValVector< T >::operator= ( const_reference  ival)

Sets all elements in self to the value ival.

template<class T>
reference RWTValVector< T >::operator[] ( size_type  i)
inline

Returns a reference to the i th value in the vector.

Exceptions
RWBoundsErrThrown if index i is not between 0 and one less than the number of entries in self.
template<class T>
const_reference RWTValVector< T >::operator[] ( size_type  i) const
inline

Returns a reference to the i th value in the vector.

Exceptions
RWBoundsErrThrown if index i is not between 0 and one less than the number of entries in self.
template<class T>
reverse_iterator RWTValVector< T >::rbegin ( )
inline

Returns an iterator referring to the last element in the container.

If the container is empty, returns rend().

template<class T>
const_reverse_iterator RWTValVector< T >::rbegin ( ) const
inline

Returns an iterator referring to the last element in the container.

If the container is empty, returns rend().

template<class T>
reverse_iterator RWTValVector< T >::rend ( )
inline

Returns an iterator referring to the element before the first element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

template<class T>
const_reverse_iterator RWTValVector< T >::rend ( ) const
inline

Returns an iterator referring to the element before the first element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

template<class T>
void RWTValVector< T >::reshape ( size_type  N)

Changes the length of the vector to N. If this increases the length of the vector, then the initial value of the additional elements is set by the default constructor of value_type.

template<class T>
void RWTValVector< T >::swap ( RWTValVector< T > &  rhs)

Swaps the data owned by self with the data owned by rhs.


© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.