DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Public Types | Public Member Functions | Protected Attributes | List of all members
OFMap< K, V > Class Template Reference

associative container class. More...

## Public Types
typedef OFPair< const K, V > | value_type
| the type of values saved in this map

## Public Member Functions
typedef | OFListIterator (value_type) iterator
| iterator class for OFMap. More...
typedef | OFListConstIterator (value_type) const _iterator
| constant iterator class for OFMap. More...
| OFMap ()
| default constructor
OFMap & | operator= (const OFMap &other)
| assignment operator
V & | operator[] (const K &key)
| index operator. More...
iterator | begin ()
| returns iterator pointing to the first element of this map More...
iterator | end ()
| returns iterator pointer after the last element of this map More...
const_iterator | begin () const
| returns constant iterator pointing to the first element of this map More...
const_iterator | end () const
| returns constant iterator pointer after the last element of this map More...
iterator | find (const K &key)
| looks up the given key in this map More...
const_iterator | find (const K &key) const
| looks up the given key in this map More...
OFBool | empty () const
| returns whether this map is empty (i.e. whether its size is 0) More...
size_t | size () const
| returns the number of elements saved in this map More...
void | clear ()
| removes all elements from this map
void | erase (const iterator &first, const iterator &last)
| removes all elements in the given range from this map More...
void | erase (const iterator &elem)
| removes the element to which the given iterator points to More...
int | erase (const K &key)
| removes the element with the given key from this map More...
OFPair< iterator, bool > | insert (const value_type &val)
| inserts a new element into the map, but does not overwrite existing elements More...
void | swap (OFMap< K, V > &s)
| swaps the contents of the two maps. More...

## Protected Attributes
OFList< value_type > | values_

## Detailed Description

### template<typename K, typename V>
class OFMap< K, V >

associative container class.

This class is a subset of std::map.

## Member Function Documentation

## ◆ begin() [1/2]

template<typename K , typename V >

iterator OFMap< K, V >::begin | ( |  | ) |
| inline

returns iterator pointing to the first element of this map

Returns
  iterator pointing to the first element of this map

References OFMap< K, V >::values_.

Referenced by OFMap< K, V >::find(), OFMap< K, V >::insert(), and OFMap< K, V >::operator=().

## ◆ begin() [2/2]

template<typename K , typename V >

const_iterator OFMap< K, V >::begin | ( |  | ) | const
| inline

returns constant iterator pointing to the first element of this map

Returns
  constant iterator pointing to the first element of this map

References OFMap< K, V >::values_.

## ◆ empty()

template<typename K , typename V >

OFBool OFMap< K, V >::empty | ( |  | ) | const
| inline

returns whether this map is empty (i.e. whether its size is 0)

Returns
  OFTrue if this map is empty, OFFalse otherwise

References OFMap< K, V >::values_.

## ◆ end() [1/2]

template<typename K , typename V >

iterator OFMap< K, V >::end | ( |  | ) |
| inline

returns iterator pointer after the last element of this map

Returns
  iterator pointer after the last element of this map

References OFMap< K, V >::values_.

Referenced by OFMap< K, V >::erase(), OFMap< K, V >::find(), OFMap< K, V >::insert(), OFMap< K, V >::operator=(), and OFMap< K, V >::operator[]().

## ◆ end() [2/2]

template<typename K , typename V >

const_iterator OFMap< K, V >::end | ( |  | ) | const
| inline

returns constant iterator pointer after the last element of this map

Returns
  constant iterator pointer after the last element of this map

References OFMap< K, V >::values_.

## ◆ erase() [1/3]

template<typename K , typename V >

void OFMap< K, V >::erase | ( | const iterator & | elem | ) |
| inline

removes the element to which the given iterator points to

Parameters

  elem | the element to remove

References OFMap< K, V >::values_.

## ◆ erase() [2/3]

template<typename K , typename V >

void OFMap< K, V >::erase | ( | const iterator & | first,
|  | const iterator & | last
| ) |  |
| inline

removes all elements in the given range from this map

Parameters

  first | the first element to remove
  last | the first element NOT to remove

References OFMap< K, V >::values_.

## ◆ erase() [3/3]

template<typename K , typename V >

int OFMap< K, V >::erase | ( | const K & | key | ) |
| inline

removes the element with the given key from this map

Returns
  the number of elements removed (0 or 1)

References OFMap< K, V >::end(), OFMap< K, V >::find(), and OFMap< K, V >::values_.

## ◆ find() [1/2]

template<typename K , typename V >

iterator OFMap< K, V >::find | ( | const K & | key | ) |
| inline

looks up the given key in this map

Parameters

  key | the key to look for

Returns
  iterator for that key to end()

References OFMap< K, V >::begin(), and OFMap< K, V >::end().

Referenced by OFMap< K, V >::erase(), OFMap< K, V >::insert(), and OFMap< K, V >::operator[]().

## ◆ find() [2/2]

template<typename K , typename V >

const_iterator OFMap< K, V >::find | ( | const K & | key | ) | const
| inline

looks up the given key in this map

Parameters

  key | the key to look for

Returns
  constant iterator for that key to end()

References OFMap< K, V >::begin(), and OFMap< K, V >::end().

## ◆ insert()

template<typename K , typename V >

OFPair<iterator, bool> OFMap< K, V >::insert | ( | const value_type & | val | ) |
| inline

inserts a new element into the map, but does not overwrite existing elements

Parameters

  val | the value to insert

Returns
  a pair of an iterator and a boolean. The iterator always points to the element which got val's key. The boolean is true if val was inserted, false otherwise.

References OFMap< K, V >::begin(), OFMap< K, V >::end(), OFMap< K, V >::find(), OFMap< K, V >::OFListIterator(), and OFMap< K, V >::values_.

Referenced by OFMap< K, V >::operator=(), and OFMap< K, V >::operator[]().

## ◆ OFListConstIterator()

template<typename K , typename V >

typedef OFMap< K, V >::OFListConstIterator | ( | value_type |  | ) | const

constant iterator class for OFMap.

You can read the elements, but you may not modify them.

## ◆ OFListIterator()

template<typename K , typename V >

typedef OFMap< K, V >::OFListIterator | ( | value_type |  | ) |

iterator class for OFMap.

You can modify elements through this iterator's ->first and ->second properties.

Referenced by OFMap< K, V >::insert().

## ◆ operator[]()

template<typename K , typename V >

V& OFMap< K, V >::operator[] | ( | const K & | key | ) |
| inline

index operator.

You can use this to add new elements to the map. Beware: Don't use this for checking if a given key is already used in the map, use find() != end() for this job!

Parameters

  key | the key you want to access

Returns
  reference to the value saved under the given key.

References OFMap< K, V >::end(), OFMap< K, V >::find(), and OFMap< K, V >::insert().

## ◆ size()

template<typename K , typename V >

size_t OFMap< K, V >::size | ( |  | ) | const
| inline

returns the number of elements saved in this map

Returns
  the number of elements saved in this map

References OFMap< K, V >::values_.

## ◆ swap()

template<typename K , typename V >

void OFMap< K, V >::swap | ( | OFMap< K, V > & | s | ) |
| inline

swaps the contents of the two maps.

The time complexity of this function should be constant.

Parameters

  s | map to swap with

References OFMap< K, V >::values_.

## Member Data Documentation

## ◆ values_

template<typename K , typename V >

OFList<value_type> OFMap< K, V >::values_
| protected

Todo:
  using a list as base is slooooow

Referenced by OFMap< K, V >::begin(), OFMap< K, V >::clear(), OFMap< K, V >::empty(), OFMap< K, V >::end(), OFMap< K, V >::erase(), OFMap< K, V >::insert(), OFMap< K, V >::size(), and OFMap< K, V >::swap().

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

- ofstd/include/dcmtk/ofstd/ofmap.h

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