rptr::Rvec< T > Class Template Reference
A vector class template allowing gaps.
More...
#include <rvec.h>
List of all members.
Detailed Description
template<class T>
class rptr::Rvec< T >
A vector class template allowing gaps.
This template class behaves much like a vector<T> class, but it also allows 'gaps' within valid index range. When erasing an element a gap is created rather than shifting all elements with higher index one step down as in a vector<T> container. In addition, the elements may be objects of any type derived from the template argument type T.
This container is a good choice if you want a convenient vector for polymorphic types and if robustness has higher priority than efficiency.
The template class fulfills the requirements for a STL container (hopefully, this should perhaps be more thorougly tested),
Feature summary:
- Random access with constant time using operator []
- Reference counting pointer used to hold elements ( rptr::Rptr )
- Can hold elements of any type derived from template argument T
- Supports gaps in valid index range
- exception mechanism is used to handle
Constructor & Destructor Documentation
Member Function Documentation
|
- Returns:
- const_iterator pointing to first non-empty element position or end() if container is empty
|
|
- Returns:
- const_iterator pointing to first non-empty element position or end() if container is empty
|
template<class T> |
void rptr::Rvec< T >::clear |
( |
|
) |
[inline] |
|
template<class T> |
bool rptr::Rvec< T >::defined |
( |
size_type |
n |
) |
const [inline] |
|
|
- Returns:
- true iff position n contains a defined element
|
template<class T> |
bool rptr::Rvec< T >::empty |
( |
|
) |
const [inline] |
|
|
- Returns:
- true iff no elements exist in container
|
template<class T> |
void rptr::Rvec< T >::erase |
( |
size_type |
pos |
) |
[inline] |
|
template<class T> |
int rptr::Rvec< T >::ibegin |
( |
|
) |
const [inline] |
|
|
- Returns:
- position of first defined element
|
|
- Returns:
- integer index of given iterator it
|
|
- Returns:
- integer index of given iterator it
|
template<class T> |
int rptr::Rvec< T >::inext |
( |
int |
id |
) |
const [inline] |
|
|
- Returns:
- position of next defined element
|
template<class T> |
size_type rptr::Rvec< T >::insert |
( |
pointer |
x |
) |
[inline] |
|
|
Insert a new object into container. - Returns:
- index of inserted object.
|
template<class T> |
int rptr::Rvec< T >::iprev |
( |
int |
id |
) |
const [inline] |
|
|
- Returns:
- position of previous defined element
|
template<class T> |
reference rptr::Rvec< T >::operator[] |
( |
size_type |
n |
) |
[inline] |
|
|
- Returns:
- element at position n. Throws
std::out_of_range if no element exists at n
|
template<class T> |
const_reference rptr::Rvec< T >::operator[] |
( |
size_type |
n |
) |
const [inline] |
|
|
- Returns:
- element at position n. Throws
std::out_of_range if no element exists at n
|
template<class T> |
pointer rptr::Rvec< T >::ptr |
( |
size_type |
n |
) |
[inline] |
|
|
- Returns:
- pointer at position n. Throws
std::out_of_range if no element exists at n
|
template<class T> |
const_pointer rptr::Rvec< T >::ptr |
( |
size_type |
n |
) |
const [inline] |
|
|
- Returns:
- pointer at position n. Throws
std::out_of_range if no element exists at n
|
template<class T> |
Rvec< T >::size_type rptr::Rvec< T >::set |
( |
size_type |
pos, |
|
|
pointer |
x |
|
) |
|
|
|
Insert a new object into container at given position. If an object existed at pos that object is replaced by the new object x. If x is NULL and element at pos is defined, then that element is erased and end() is returned.
- pos Position where the new object will be inserted
- Returns:
- index of inserted object or end() if x was NULL.
|
template<class T> |
size_type rptr::Rvec< T >::size |
( |
|
) |
const [inline] |
|
|
- Returns:
- number of elements in container (not counting empty positions)
|
template<class T> |
void rptr::Rvec< T >::swap |
( |
const Rvec< T > & |
src |
) |
[inline] |
|
|
Swap contents of src and this container |
The documentation for this class was generated from the following file:
Generated on Wed May 12 15:35:34 2004 for rptr by
1.3.3