DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Types | Public Member Functions | Protected Attributes
OFVector< T > Class Template Reference

this is a resizable array. More...

List of all members.

Public Types

typedef T value_type
 the type of elements that this OFVector stores
typedef size_t size_type
 the type used for sizes and indexes
typedef T * iterator
 the type of mutable iterators on this object
typedef const T * const_iterator
 the type of constant iterators on this object

Public Member Functions

 OFVector ()
 default constructor.
 OFVector (const OFVector &other)
 copy constructor.
 OFVector (size_type n, const T &v=T())
 construct an OFVector with predefined content.
 OFVector (const_iterator from, const_iterator to)
 construct an OFVector from a range of iterators.
 ~OFVector ()
 destructor.
OFVectoroperator= (const OFVector &other)
 assignment operator.
void swap (OFVector &other)
 swap this vector's content with some other vector.
iterator begin ()
 get an iterator for the first element in this object.
const_iterator begin () const
 get an iterator for the first element in this object.
iterator end ()
 get an iterator that points past the last valid object.
const_iterator end () const
 get an iterator that points past the last valid object.
size_type size () const
 get the size of this OFVector.
OFBool empty () const
 check wether this OFVector is empty.
void clear ()
 clear this OFVector.
void erase (iterator it)
 removes an entry from this OFVector.
iterator insert (iterator it, const T &v)
 insert an entry in this OFVector.
template<class InputIterator >
void insert (iterator it, InputIterator from, InputIterator to)
 insert a range of elements in this OFVector.
void push_back (const T &v)
 insert an entry at the end of this object
void pop_back ()
 remove the last entry in this object
T & operator[] (size_type i)
 access an entry by index.
const T & operator[] (size_type i) const
 access an entry by index.
T & at (size_type i)
 access an entry by index.
const T & at (size_type i) const
 access an entry by index.
void resize (size_type n, T v=T())
 resize this OFVector.
void reserve (size_type n)
 reserves enough space for the given number of elements.

Protected Attributes

T * values_
 array that is used for storing the entries in this OFVector
size_type allocated_
 the size for which values_ was allocated
size_type size_
 the number of valid entries in values_.

Detailed Description

template<typename T>
class OFVector< T >

this is a resizable array.

You can add and remove elements after it was created and this class will handle all the memory management needed. This implements parts of std::vector's features.


Constructor & Destructor Documentation

template<typename T>
OFVector< T >::OFVector ( ) [inline]

default constructor.

This creates an empty OFVector.

template<typename T>
OFVector< T >::OFVector ( const OFVector< T > &  other) [inline]

copy constructor.

Parameters:
otherOFVector from which all elements are copied
template<typename T>
OFVector< T >::OFVector ( size_type  n,
const T &  v = T() 
) [inline, explicit]

construct an OFVector with predefined content.

Parameters:
nnumber of elements that this OFVector should have.
vThe value used for all elements.
template<typename T>
OFVector< T >::OFVector ( const_iterator  from,
const_iterator  to 
) [inline]

construct an OFVector from a range of iterators.

Parameters:
fromfirst iterator to include
tofirst iterator that should not be included anymore
template<typename T>
OFVector< T >::~OFVector ( ) [inline]

destructor.

Frees all memory used by this object.


Member Function Documentation

template<typename T>
T& OFVector< T >::at ( size_type  i) [inline]

access an entry by index.

Parameters:
iindex of the element to return
Returns:
reference to the element.
template<typename T>
const T& OFVector< T >::at ( size_type  i) const [inline]

access an entry by index.

Parameters:
iindex of the element to return
Returns:
reference to the element.
template<typename T>
iterator OFVector< T >::begin ( ) [inline]

get an iterator for the first element in this object.

Returns:
iterator that points to the first element.
template<typename T>
const_iterator OFVector< T >::begin ( ) const [inline]

get an iterator for the first element in this object.

Returns:
iterator that points to the first element.
template<typename T>
void OFVector< T >::clear ( ) [inline]

clear this OFVector.

The existing content will be freed and all iterators become invalid.

template<typename T>
OFBool OFVector< T >::empty ( ) const [inline]

check wether this OFVector is empty.

Returns:
true if this OFVector is empty.
template<typename T>
iterator OFVector< T >::end ( ) [inline]

get an iterator that points past the last valid object.

Returns:
iterator that points to the end of this OFVector.
template<typename T>
const_iterator OFVector< T >::end ( ) const [inline]

get an iterator that points past the last valid object.

Returns:
iterator that points to the end of this OFVector.
template<typename T>
void OFVector< T >::erase ( iterator  it) [inline]

removes an entry from this OFVector.

All iterators pointing to the element removed or elements that come behind it in this OFVector will become invalid.

Parameters:
ititerator for the entry that should be removed.
template<typename T>
iterator OFVector< T >::insert ( iterator  it,
const T &  v 
) [inline]

insert an entry in this OFVector.

All iterators for this OFVector become invalid.

Parameters:
itthe new element will be inserted in front of the element to which this iterator points.
vthe element to insert
Returns:
iterator for the newly inserted element.
template<typename T>
template<class InputIterator >
void OFVector< T >::insert ( iterator  it,
InputIterator  from,
InputIterator  to 
) [inline]

insert a range of elements in this OFVector.

All iterators for this OFVector become invalid.

Parameters:
itthe new elements will be inserted in front of the element to which this iterator points.
fromiterator to the beginning of the range to insert.
toiterator past the end of the range to insert.
template<typename T>
OFVector& OFVector< T >::operator= ( const OFVector< T > &  other) [inline]

assignment operator.

All elements from this object are removed and then a copy of other is made. All iterators to this object will become invalid.

Parameters:
otherOFVector instance to copy elements from.
template<typename T>
T& OFVector< T >::operator[] ( size_type  i) [inline]

access an entry by index.

undefined behavior occurs when the index is out of bounds (bigger than the maximum allowed index).

Parameters:
iindex of the element to return
Returns:
reference to the element.
template<typename T>
const T& OFVector< T >::operator[] ( size_type  i) const [inline]

access an entry by index.

undefined behavior occurs when the index is out of bounds (bigger than the maximum allowed index).

Parameters:
iindex of the element to return
Returns:
reference to the element.
template<typename T>
void OFVector< T >::push_back ( const T &  v) [inline]

insert an entry at the end of this object

Parameters:
vthe value to insert
template<typename T>
void OFVector< T >::reserve ( size_type  n) [inline]

reserves enough space for the given number of elements.

from now on, no memory allocations will occur as long as this OFVector's size stays below n and clear() is not called.

Parameters:
nthe number of elements for which space should be reserved.
template<typename T>
void OFVector< T >::resize ( size_type  n,
v = T() 
) [inline]

resize this OFVector.

after this call, size() will be n.

Parameters:
nthe new size that this object should use
vif any new elements need to be inserted, they get this value.
template<typename T>
size_type OFVector< T >::size ( ) const [inline]

get the size of this OFVector.

Returns:
number of elements in this instance.
template<typename T>
void OFVector< T >::swap ( OFVector< T > &  other) [inline]

swap this vector's content with some other vector.

All iterators will stay valid.

Parameters:
otherobject to swap with

Member Data Documentation

template<typename T>
size_type OFVector< T >::size_ [protected]

the number of valid entries in values_.

elements past this index have undefined content.


The documentation for this class was generated from the following file:


Generated on Tue May 15 2012 for DCMTK Version 3.6.1 20120515 by Doxygen 1.7.5.1-20111027