Main Page | Compound List | File List | Compound Members

rptr::Rvec< T > Class Template Reference

A vector class template allowing gaps. More...

#include <rvec.h>

List of all members.

Public Member Functions

Construction
 Rvec ()
const
const_reference operator[] (size_type n) const
const_pointer ptr (size_type n) const
const_iterator begin () const
const_iterator end () const
int ibegin () const
int inext (int id) const
int iprev (int id) const
size_type id (const iterator &it) const
size_type id (const const_iterator &it) const
size_type size () const
bool defined (size_type n) const
bool empty () const
nonconst
iterator begin ()
iterator end ()
pointer ptr (size_type n)
reference operator[] (size_type n)
void swap (const Rvec &src)
size_type insert (pointer x)
size_type set (size_type pos, pointer x)
void erase (size_type pos)
void erase (const iterator &i)
void clear ()


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:


Constructor & Destructor Documentation

template<class T>
rptr::Rvec< T >::Rvec  )  [inline]
 

Default constructor


Member Function Documentation

template<class T>
iterator rptr::Rvec< T >::begin  )  [inline]
 

Returns:
const_iterator pointing to first non-empty element position or end() if container is empty

template<class T>
const_iterator rptr::Rvec< T >::begin  )  const [inline]
 

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]
 

Erase all elements

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>
iterator rptr::Rvec< T >::end  )  [inline]
 

Returns:
const_iterator after last defined element position

template<class T>
const_iterator rptr::Rvec< T >::end  )  const [inline]
 

Returns:
const_iterator after last defined element position

template<class T>
void rptr::Rvec< T >::erase const iterator i  ) 
 

Erase an element

template<class T>
void rptr::Rvec< T >::erase size_type  pos  )  [inline]
 

Erase an element

template<class T>
int rptr::Rvec< T >::ibegin  )  const [inline]
 

Returns:
position of first defined element

template<class T>
size_type rptr::Rvec< T >::id const const_iterator it  )  const [inline]
 

Returns:
integer index of given iterator it

template<class T>
size_type rptr::Rvec< T >::id const iterator it  )  const [inline]
 

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 doxygen 1.3.3