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
RWTPtrVector< T > Class Template Reference

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

#include <rw/tpvector.h>

Inherits RWPtrVector.

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

 RWTPtrVector ()
 
 RWTPtrVector (size_type n)
 
 RWTPtrVector (size_type n, value_type ival)
 
 RWTPtrVector (const RWTPtrVector< T > &rhs)
 
 RWTPtrVector (RWTPtrVector< T > &&rhs)
 
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
 
RWTPtrVector< T > & operator= (const RWTPtrVector< T > &rhs)
 
RWTPtrVector< T > & operator= (RWTPtrVector< T > &&rhs)
 
RWTPtrVector< T > & operator= (value_type p)
 
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 resize (size_type N)
 
void swap (RWTPtrVector< T > &rhs)
 

Detailed Description

template<class T>
class RWTPtrVector< T >

Class RWTPtrVector<T> is a simple parameterized vector of pointers to objects of type T. It is most useful when you know precisely how many pointers must be held in the collection. If the intention is to insert an unknown number of objects into a collection, then class RWTPtrOrderedVector<T,A> may be a better choice. Class T can be of any type.

Synopsis

#include <rw/tpvector.h>

Persistence

Isomorphic

Example

#include <iostream>
#include <rw/tpvector.h>
#include <rw/tools/datetime.h>
int main ()
{
for (size_t i = 0; i < 7; ++i) {
week[i] = new RWDateTime(begin);
begin.incrementDay(1);
}
for (size_t i = 0; i < 7; ++i) {
std::cout << week[i]->asString('x') << std::endl;
delete week[i];
}
return 0;
}

Program output (if run on June 18, 2009):

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

Member Typedef Documentation

template<class T>
typedef const_pointer RWTPtrVector< 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* RWTPtrVector< T >::const_pointer

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

template<class T>
typedef const value_type& RWTPtrVector< 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> RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< T >::iterator

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

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

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

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

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

template<class T>
typedef std::reverse_iterator<iterator> RWTPtrVector< 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 RWTPtrVector< T >::size_type

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

template<class T>
typedef T* RWTPtrVector< T >::value_type

A type representing the container's data type.

Constructor & Destructor Documentation

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

Constructs an empty vector of length zero.

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

Constructs a vector of length n. The initial values of the elements are undefined. Hence, they can (and probably will) be garbage.

template<class T>
RWTPtrVector< T >::RWTPtrVector ( size_type  n,
value_type  ival 
)
inline

Constructs a vector of length n, with each element pointing to the item ival.

template<class T>
RWTPtrVector< T >::RWTPtrVector ( const RWTPtrVector< T > &  rhs)
inline

Copy constructor. The constructed vector is a shallow copy of rhs. The two vectors will then have the same length, and pointers held by the two vectors will point to the same items.

template<class T>
RWTPtrVector< T >::RWTPtrVector ( RWTPtrVector< T > &&  rhs)
inline

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.

Member Function Documentation

template<class T>
iterator RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< T >::length ( ) const
inline

Returns the length of the vector.

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

Returns the i th value in the vector. The index i must be between zero and the length of the vector, less one. No bounds checking is performed.

template<class T>
const_reference RWTPtrVector< T >::operator() ( size_type  i) const
inline

Returns the i th value in the vector. The index i must be between zero and the length of the vector, less one. No bounds checking is performed.

template<class T>
RWTPtrVector<T>& RWTPtrVector< T >::operator= ( const RWTPtrVector< T > &  rhs)
inline

Sets self to a shallow copy of rhs. The two vectors will then have the same length, and pointers held by the two vectors will point to the same items.

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

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>
RWTPtrVector<T>& RWTPtrVector< T >::operator= ( value_type  p)
inline

Sets all elements in self to point to the item p.

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

Returns the i th value in the vector.

Exceptions
RWBoundsErrThrown if the index i is not between zero and the length of the vector, less one.
template<class T>
const_reference RWTPtrVector< T >::operator[] ( size_type  i) const
inline

Returns the i th value in the vector.

Exceptions
RWBoundsErrThrown if the index i is not between zero and the length of the vector, less one.
template<class T>
reverse_iterator RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< 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 RWTPtrVector< T >::reshape ( size_type  N)
inline

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 undefined.

template<class T>
void RWTPtrVector< T >::resize ( size_type  N)
inline

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 to rwnil.

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

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.