SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A pointer-based collection of values implemented as a vector. More...
#include <rw/tpvector.h>
Inherits RWPtrVector.
Public Member Functions | |
RWTPtrVector () | |
RWTPtrVector (size_t n) | |
RWTPtrVector (size_t n, T *ival) | |
RWTPtrVector (const RWTPtrVector< T > &v) | |
RWTPtrVector (RWTPtrVector< T > &&v) | |
RWTPtrVector< T > & | operator= (const RWTPtrVector< T > &v) |
RWTPtrVector< T > & | operator= (RWTPtrVector< T > &&v) |
RWTPtrVector< T > & | operator= (T *p) |
T *& | operator() (size_t i) |
T *const & | operator() (size_t i) const |
T *& | operator[] (size_t i) |
T *const & | operator[] (size_t i) const |
T *const * | data () const |
size_t | length () const |
void | reshape (size_t N) |
void | resize (size_t N) |
void | swap (RWTPtrVector< T > &v) |
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.
#include <rw/tpvector.h> RWTPtrVector<T> vec;
Isomorphic
#include <iostream> #include <rw/tpvector.h> #include <rw/tools/datetime.h> int main () { RWTPtrVector<RWDateTime> week(7); RWDateTime begin(RWDateTime::setCurrentTime); // Today's date 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
RWTPtrVector< T >::RWTPtrVector | ( | ) | [inline] |
Constructs an empty vector of length zero.
RWTPtrVector< T >::RWTPtrVector | ( | size_t | n | ) | [inline] |
Constructs a vector of length n. The initial values of the elements are undefined. Hence, they can (and probably will) be garbage.
RWTPtrVector< T >::RWTPtrVector | ( | size_t | n, | |
T * | ival | |||
) | [inline] |
Constructs a vector of length n, with each element pointing to the item ival.
RWTPtrVector< T >::RWTPtrVector | ( | const RWTPtrVector< T > & | v | ) | [inline] |
Copy constructor. The constructed vector is a shallow copy of v. The two vectors will then have the same length, and pointers held by the two vectors will point to the same items.
RWTPtrVector< T >::RWTPtrVector | ( | RWTPtrVector< T > && | v | ) | [inline] |
Move constructor. The constructed vector takes ownership of the data owned by v.
T* const* RWTPtrVector< T >::data | ( | void | ) | const [inline] |
Returns a pointer to the raw data of the vector.
size_t RWTPtrVector< T >::length | ( | ) | const [inline] |
Returns the length of the vector.
T* const& RWTPtrVector< T >::operator() | ( | size_t | 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.
T*& RWTPtrVector< T >::operator() | ( | size_t | 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.
RWTPtrVector<T>& RWTPtrVector< T >::operator= | ( | T * | p | ) | [inline] |
Sets all elements in self to point to the item p.
RWTPtrVector<T>& RWTPtrVector< T >::operator= | ( | RWTPtrVector< T > && | v | ) | [inline] |
Move assignment. Self takes ownership of the data owned by v.
RWTPtrVector<T>& RWTPtrVector< T >::operator= | ( | const RWTPtrVector< T > & | v | ) | [inline] |
Sets self to a shallow copy of v. The two vectors will then have the same length, and pointers held by the two vectors will point to the same items.
T* const& RWTPtrVector< T >::operator[] | ( | size_t | i | ) | const [inline] |
Returns the i th value in the vector.
RWBoundsErr | Thrown if the index i is not between zero and the length of the vector, less one. |
T*& RWTPtrVector< T >::operator[] | ( | size_t | i | ) | [inline] |
Returns the i th value in the vector.
RWBoundsErr | Thrown if the index i is not between zero and the length of the vector, less one. |
void RWTPtrVector< T >::reshape | ( | size_t | 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.
void RWTPtrVector< T >::resize | ( | size_t | 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.
void RWTPtrVector< T >::swap | ( | RWTPtrVector< T > & | v | ) | [inline] |
Swaps the data owned by self with the data owned by v.
© 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.
Contact Rogue Wave about documentation or support issues.