DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Public Types | Public Member Functions | Protected Attributes | List of all members
OFVector< T > Class Template Reference

this is a resizable array. More...

## 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
typedef T & | reference
| the type of mutable references on this object
typedef const T & | const_reference
| the type of constant references on this object

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

## 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_. More...

## 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

## ◆ OFVector() [1/4]

template<typename T >

OFVector< T >::OFVector | ( |  | ) |
| inline

default constructor.

This creates an empty OFVector.

## ◆ OFVector() [2/4]

template<typename T >

OFVector< T >::OFVector | ( | const OFVector< T > & | other | ) |
| inline

copy constructor.

Parameters

  other | OFVector from which all elements are copied

References OFVector< T >::begin(), OFVector< T >::end(), OFVector< T >::push_back(), OFVector< T >::reserve(), and OFVector< T >::size().

## ◆ OFVector() [3/4]

template<typename T >

OFVector< T >::OFVector | ( | size_type | n,
|  | const T & | v = `T()`
| ) |  |
| inline explicit

construct an OFVector with predefined content.

Parameters

  n | number of elements that this OFVector should have.
  v | The value used for all elements.

References OFVector< T >::reserve(), and OFVector< T >::resize().

## ◆ OFVector() [4/4]

template<typename T >

OFVector< T >::OFVector | ( | const_iterator | from,
|  | const_iterator | to
| ) |  |
| inline

construct an OFVector from a range of iterators.

Parameters

  from | first iterator to include
  to | first iterator that should not be included anymore

References OFVector< T >::push_back(), and OFVector< T >::reserve().

## ◆ ~OFVector()

template<typename T >

OFVector< T >::~OFVector | ( |  | ) |
| inline

destructor.

Frees all memory used by this object.

References OFVector< T >::values_.

## Member Function Documentation

## ◆ at() [1/2]

template<typename T >

T& OFVector< T >::at | ( | size_type | i | ) |
| inline

access an entry by index.

Parameters

  i | index of the element to return

Returns
  reference to the element.

References OFVector< T >::size_.

## ◆ at() [2/2]

template<typename T >

const T& OFVector< T >::at | ( | size_type | i | ) | const
| inline

access an entry by index.

Parameters

  i | index of the element to return

Returns
  reference to the element.

References OFVector< T >::size_.

## ◆ back() [1/2]

template<typename T >

T& OFVector< T >::back | ( |  | ) |
| inline

get a reference to the last element of this vector.

Returns
  reference to the last element.

References OFVector< T >::size_, and OFVector< T >::values_.

## ◆ back() [2/2]

template<typename T >

const T& OFVector< T >::back | ( |  | ) | const
| inline

get a reference to the last element of this vector.

Returns
  reference to the last element.

References OFVector< T >::size_, and OFVector< T >::values_.

## ◆ begin() [1/2]

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.

References OFVector< T >::values_.

Referenced by OFVector< T >::OFVector(), OFVector< T >::erase(), OFVector< T >::insert(), and OFVector< T >::operator=().

## ◆ begin() [2/2]

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.

References OFVector< T >::values_.

## ◆ clear()

template<typename T >

void OFVector< T >::clear | ( |  | ) |
| inline

clear this OFVector.

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

References OFVector< T >::allocated_, OFVector< T >::reserve(), OFVector< T >::size_, and OFVector< T >::values_.

Referenced by FrameSorter::Results::clear(), DSRListOfItems< T >::getItems(), and OFVector< T >::operator=().

## ◆ empty()

template<typename T >

OFBool OFVector< T >::empty | ( |  | ) | const
| inline

check whether this OFVector is empty.

Returns
  true if this OFVector is empty.

References OFVector< T >::size_.

## ◆ end() [1/2]

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.

References OFVector< T >::size_, and OFVector< T >::values_.

Referenced by OFVector< T >::OFVector(), OFVector< T >::operator=(), OFVector< T >::pop_back(), and OFVector< T >::push_back().

## ◆ end() [2/2]

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.

References OFVector< T >::size_, and OFVector< T >::values_.

## ◆ erase()

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

  it | iterator for the entry that should be removed.

References OFVector< T >::begin(), OFVector< T >::size_, and OFVector< T >::values_.

Referenced by OFVector< T >::pop_back().

## ◆ front() [1/2]

template<typename T >

T& OFVector< T >::front | ( |  | ) |
| inline

get a reference to the first element of this vector.

Returns
  reference to the first element.

References OFVector< T >::values_.

## ◆ front() [2/2]

template<typename T >

const T& OFVector< T >::front | ( |  | ) | const
| inline

get a reference to the first element of this vector.

Returns
  reference to the first element.

References OFVector< T >::values_.

## ◆ insert() [1/2]

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

  it | the new element will be inserted in front of the element to which this iterator points.
  v | the element to insert

Returns
  iterator for the newly inserted element.

References OFVector< T >::allocated_, OFVector< T >::begin(), OFVector< T >::reserve(), OFVector< T >::size_, and OFVector< T >::values_.

Referenced by OFVector< T >::insert(), and OFVector< T >::push_back().

## ◆ insert() [2/2]

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

  it | the new elements will be inserted in front of the element to which this iterator points.
  from | iterator to the beginning of the range to insert.
  to | iterator past the end of the range to insert.

References OFVector< T >::insert().

## ◆ operator=()

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

  other | OFVector instance to copy elements from.

References OFVector< T >::begin(), OFVector< T >::clear(), OFVector< T >::end(), OFVector< T >::push_back(), OFVector< T >::reserve(), and OFVector< T >::size().

## ◆ operator[]() [1/2]

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

  i | index of the element to return

Returns
  reference to the element.

References OFVector< T >::values_.

## ◆ operator[]() [2/2]

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

  i | index of the element to return

Returns
  reference to the element.

References OFVector< T >::values_.

## ◆ push_back()

template<typename T >

void OFVector< T >::push_back | ( | const T & | v | ) |
| inline

insert an entry at the end of this object

Parameters

  v | the value to insert

References OFVector< T >::end(), and OFVector< T >::insert().

Referenced by OFVector< T >::OFVector(), FrameSorterIPP::cross_3d(), DSRListOfItems< T >::getItems(), OFVector< T >::operator=(), FrameSorterIdentity::sort(), and dcmtk::log4cplus::helpers::tokenize().

## ◆ reserve()

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

  n | the number of elements for which space should be reserved.

References OFVector< T >::allocated_, OFVector< T >::size_, and OFVector< T >::values_.

Referenced by OFVector< T >::OFVector(), OFVector< T >::clear(), DSRListOfItems< T >::getItems(), OFVector< T >::insert(), OFVector< T >::operator=(), and OFVector< T >::resize().

## ◆ resize()

template<typename T >

void OFVector< T >::resize | ( | size_type | n,
|  | T | v = `T()`
| ) |  |
| inline

resize this OFVector.

after this call, size() will be n.

Parameters

  n | the new size that this object should use
  v | if any new elements need to be inserted, they get this value.

References OFVector< T >::reserve(), OFVector< T >::size_, and OFVector< T >::values_.

Referenced by OFVector< T >::OFVector().

## ◆ size()

template<typename T >

size_type OFVector< T >::size | ( |  | ) | const
| inline

get the size of this OFVector.

Returns
  number of elements in this instance.

References OFVector< T >::size_.

Referenced by OFVector< T >::OFVector(), DcmSegmentation::addFrame(), and OFVector< T >::operator=().

## ◆ swap()

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

  other | object to swap with

References OFVector< T >::allocated_, OFVector< T >::size_, and OFVector< T >::values_.

## Member Data Documentation

## ◆ size_

template<typename T >

size_type OFVector< T >::size_
| protected

the number of valid entries in values_.

elements past this index have undefined content.

Referenced by OFVector< T >::at(), OFVector< T >::back(), OFVector< T >::clear(), OFVector< T >::empty(), OFVector< T >::end(), OFVector< T >::erase(), OFVector< T >::insert(), OFVector< T >::reserve(), OFVector< T >::resize(), OFVector< T >::size(), and OFVector< T >::swap().

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

- ofstd/include/dcmtk/ofstd/ofvector.h

Generated on Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1