33 #include "dcmtk/config/osconfig.h" 35 #if defined(HAVE_STL) || defined(HAVE_STL_MAP) 39 #define OFMap std::map 40 #define OFPair std::pair 41 #define OFMake_pair std::make_pair 44 #include "dcmtk/ofstd/oftypes.h" 45 #include "dcmtk/ofstd/ofcast.h" 46 #include "dcmtk/ofstd/oflist.h" 48 #ifndef HAVE_CLASS_TEMPLATE 49 #error Your C++ compiler cannot handle class templates: 55 template<
typename K,
typename V>
class OFPair 72 OFPair(
const K& f,
const V& s) : first(f), second(s) { }
89 template<
typename K,
typename V>
97 template<
typename K,
typename V>
class OFMap 114 typedef OFListIterator(value_type) iterator;
119 typedef OFListConstIterator(value_type) const_iterator;
129 for (const_iterator it = other.
begin();
130 it != other.
end(); it++)
144 iterator it = find(key);
147 it = insert(value_type(key, V())).first;
171 const_iterator
end()
const {
return values_.
end(); }
179 iterator it = begin();
182 if (it->first == key)
194 const_iterator
find(
const K& key)
const 196 const_iterator it = begin();
199 if (it->first == key)
221 values_.
erase(first, last);
237 iterator it = find(key);
254 OFListIterator(value_type) it = find(val.
first);
256 return OFMake_pair(it,
false);
259 return OFMake_pair(it,
true);
OFPair & operator=(const OFPair &other)
copy assignment operator
OFPair()
default constructor
void clear()
removes all elements from the list.
associative container class.
OFPair(const K &f, const V &s)
construct a OFPair for the two given values
a pair - this implements parts of std::pair's interface.
OFPair< iterator, bool > insert(const value_type &val)
inserts a new element into the map, but does not overwrite existing elements
iterator begin()
returns iterator pointing to the first element of this map
OFIterator< T > insert(OFIterator< T > position, const T &x)
inserts an element into the list before the given position.
OFList< value_type > values_
K first
this is the first value of the pair
void clear()
removes all elements from this map
int erase(const K &key)
removes the element with the given key from this map
const_iterator begin() const
returns constant iterator pointing to the first element of this map
void erase(const iterator &first, const iterator &last)
removes all elements in the given range from this map
OFPair< K, V > value_type
the type of values saved in this map
OFMap & operator=(const OFMap &other)
copy constructor
iterator end()
returns iterator pointer after the last element of this map
double linked list template class.
V & operator[](const K &key)
index operator.
iterator find(const K &key)
looks up the given key in this map
OFIterator< T > erase(OFIterator< T > position)
removes the element at the given position from the list.
V second
this is the second value of the pair
size_t size() const
returns the number of elements saved in this map
OFIterator< T > begin() const
returns an iterator referencing the first element in the list.
size_t size() const
returns number of elements in the list.
OFIterator< T > end() const
returns an iterator which points to the past-to-end element of the list.
void erase(const iterator &elem)
removes the element to which the given iterator points to
const_iterator find(const K &key) const
looks up the given key in this map
const_iterator end() const
returns constant iterator pointer after the last element of this map