LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
shims::map< Key, T, Compare, Allocator > Class Template Reference

#include "stdmap_shims.h"

Classes

struct  iter
 
struct  iterator_tuple
 
struct  maps_tuple
 

Public Types

using mapmap_t = typename std::map< const Key, T, Compare, Allocator >
 
using listmap_t = typename std::list< std::pair< const Key, T >, Allocator >
 
using size_type = typename mapmap_t::size_type
 
using iterator_tag = std::input_iterator_tag
 
using iterator = iter< iterator_tag, std::pair< const Key, T >>
 
using const_iterator = iter< iterator_tag, const std::pair< const Key, T >>
 

Public Member Functions

T & operator[] (Key const &key)
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
T & at (Key const &key)
 
T const & at (Key const &key) const
 
iterator find (Key const &key)
 
const_iterator find (Key const &key) const
 
size_t erase (Key const &key)
 
bool empty () const
 
size_type size () const
 
iterator erase (iterator it)
 
iterator erase (const_iterator &it)
 
template<class... Args>
std::pair< iterator, bool > emplace (Args &&...args)
 

Public Attributes

maps_tuple _maps
 

Detailed Description

template<class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
class shims::map< Key, T, Compare, Allocator >

Definition at line 21 of file stdmap_shims.h.

Member Typedef Documentation

template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
using shims::map< Key, T, Compare, Allocator >::const_iterator = iter<iterator_tag, const std::pair<const Key, T>>

Definition at line 133 of file stdmap_shims.h.

template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
using shims::map< Key, T, Compare, Allocator >::iterator = iter<iterator_tag, std::pair<const Key, T>>

Definition at line 132 of file stdmap_shims.h.

template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
using shims::map< Key, T, Compare, Allocator >::iterator_tag = std::input_iterator_tag

Definition at line 43 of file stdmap_shims.h.

template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
using shims::map< Key, T, Compare, Allocator >::listmap_t = typename std::list<std::pair<const Key, T>, Allocator>

Definition at line 24 of file stdmap_shims.h.

template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
using shims::map< Key, T, Compare, Allocator >::mapmap_t = typename std::map<const Key, T, Compare, Allocator>

Definition at line 23 of file stdmap_shims.h.

template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
using shims::map< Key, T, Compare, Allocator >::size_type = typename mapmap_t::size_type

Definition at line 41 of file stdmap_shims.h.

Member Function Documentation

template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
T& shims::map< Key, T, Compare, Allocator >::at ( Key const &  key)
inline

Definition at line 199 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

200  {
201  if (isSnippetMode()) {
202  auto it =
203  std::find_if(_maps.listmap.begin(),
204  _maps.listmap.end(),
205  [&key](auto& element) { return element.first == key; });
206  if (it == _maps.listmap.end())
207  throw std::out_of_range("Key <" + key + "> not found.");
208  return it->second;
209  } else {
210  return _maps.mapmap.at(key);
211  }
212  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
T const& shims::map< Key, T, Compare, Allocator >::at ( Key const &  key) const
inline

Definition at line 215 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

216  {
217  if (isSnippetMode()) {
218  auto it = std::find_if(
219  _maps.listmap.cbegin(),
220  _maps.listmap.cend(),
221  [&key](auto const& element) { return element.first == key; });
222  if (it == _maps.listmap.cend())
223  throw std::out_of_range("Key <" + key + "> not found.");
224  return it->second;
225  } else {
226  return _maps.mapmap.at(key);
227  }
228  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
iterator shims::map< Key, T, Compare, Allocator >::begin ( )
inline
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
const_iterator shims::map< Key, T, Compare, Allocator >::begin ( ) const
inline

Definition at line 162 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, evd::details::begin(), shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

163  {
164  maps_tuple& maps = *const_cast<maps_tuple*>(&_maps);
165 
166  return isSnippetMode() ? const_iterator{std::begin(maps.listmap)} :
167  const_iterator{std::begin(maps.mapmap)};
168  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
const_iterator shims::map< Key, T, Compare, Allocator >::cbegin ( ) const
inline

Definition at line 171 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::begin().

Referenced by fhicl::extended_value::to_string().

172  {
173  return begin();
174  }
iterator begin()
Definition: stdmap_shims.h:155
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
const_iterator shims::map< Key, T, Compare, Allocator >::cend ( ) const
inline

Definition at line 193 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::end().

Referenced by fhicl::extended_value::to_string().

194  {
195  return end();
196  }
iterator end()
Definition: stdmap_shims.h:177
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
template<class... Args>
std::pair<iterator, bool> shims::map< Key, T, Compare, Allocator >::emplace ( Args &&...  args)
inline

Definition at line 315 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

316  {
317  if (isSnippetMode()) {
318  _maps.listmap.emplace_back(std::forward<Args>(args)...);
319  return std::make_pair(iterator{std::prev(_maps.listmap.end())}, true);
320  } else {
321  auto result = _maps.mapmap.emplace(std::forward<Args>(args)...);
322  return std::make_pair(iterator{result.first}, result.second);
323  }
324  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
bool shims::map< Key, T, Compare, Allocator >::empty ( void  ) const
inline
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
iterator shims::map< Key, T, Compare, Allocator >::end ( void  )
inline
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
const_iterator shims::map< Key, T, Compare, Allocator >::end ( void  ) const
inline

Definition at line 184 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, evd::details::end(), shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

185  {
186  maps_tuple& maps = *const_cast<maps_tuple*>(&_maps);
187 
188  return isSnippetMode() ? const_iterator{std::end(maps.listmap)} :
189  const_iterator{std::end(maps.mapmap)};
190  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
size_t shims::map< Key, T, Compare, Allocator >::erase ( Key const &  key)
inline

Definition at line 259 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, e, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

Referenced by fhicl::intermediate_table::pre_insert_().

260  {
261  if (isSnippetMode()) {
262  auto erase_count = size_t{0};
263  auto i = _maps.listmap.begin();
264  auto e = _maps.listmap.end();
265 
266  while (i != e) {
267  if (key == i->first) {
268  i = _maps.listmap.erase(i);
269  ++erase_count;
270  } else {
271  i++;
272  }
273  }
274 
275  return erase_count;
276  } else {
277  return _maps.mapmap.erase(key);
278  }
279  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
Float_t e
Definition: plot.C:34
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
iterator shims::map< Key, T, Compare, Allocator >::erase ( iterator  it)
inline

Definition at line 294 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::map< Key, T, Compare, Allocator >::iter< Category, TT, Distance, Pointer, Reference >::get(), shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

295  {
296  if (isSnippetMode()) {
297  return _maps.listmap.erase(it.get(typename listmap_t::iterator{}));
298  } else {
299  return _maps.mapmap.erase(it.get(typename mapmap_t::iterator{}));
300  }
301  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
intermediate_table::iterator iterator
maps_tuple _maps
Definition: stdmap_shims.h:326
std::enable_if< std::is_same< typename mapmap_t::iterator, II >::value, II >::type get(II)
Definition: stdmap_shims.h:97
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
iterator shims::map< Key, T, Compare, Allocator >::erase ( const_iterator it)
inline

Definition at line 304 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::map< Key, T, Compare, Allocator >::iter< Category, TT, Distance, Pointer, Reference >::get(), shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

305  {
306  if (isSnippetMode()) {
307  return _maps.listmap.erase(it.get(typename listmap_t::iterator{}));
308  } else {
309  return _maps.mapmap.erase(it.get(typename mapmap_t::iterator{}));
310  }
311  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
intermediate_table::iterator iterator
maps_tuple _maps
Definition: stdmap_shims.h:326
std::enable_if< std::is_same< typename mapmap_t::iterator, II >::value, II >::type get(II)
Definition: stdmap_shims.h:97
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
iterator shims::map< Key, T, Compare, Allocator >::find ( Key const &  key)
inline

Definition at line 231 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

Referenced by fhicl::intermediate_table::erase(), fhicl::intermediate_table::exists(), fhicl::intermediate_table::find(), and fhicl::intermediate_table::pre_insert_().

232  {
233  if (isSnippetMode()) {
234  return std::find_if(
235  _maps.listmap.begin(), _maps.listmap.end(), [&key](auto& element) {
236  return element.first == key;
237  });
238  } else {
239  return _maps.mapmap.find(key);
240  }
241  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
const_iterator shims::map< Key, T, Compare, Allocator >::find ( Key const &  key) const
inline

Definition at line 244 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

245  {
246  maps_tuple& maps = *const_cast<maps_tuple*>(&_maps);
247 
248  if (isSnippetMode()) {
249  return std::find_if(
250  maps.listmap.begin(),
251  maps.listmap.end(),
252  [&key](auto const& element) { return element.first == key; });
253  } else {
254  return maps.mapmap.find(key);
255  }
256  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
T& shims::map< Key, T, Compare, Allocator >::operator[] ( Key const &  key)
inline

Definition at line 140 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, and shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap.

141  {
142  if (isSnippetMode()) {
143  for (auto& element : _maps.listmap) {
144  if (element.first == key)
145  return element.second;
146  }
147  _maps.listmap.emplace_back(std::make_pair(key, T{}));
148  return _maps.listmap.back().second;
149  } else {
150  return _maps.mapmap[key];
151  }
152  }
bool isSnippetMode(bool m)
Definition: parse_shims.cc:9
maps_tuple _maps
Definition: stdmap_shims.h:326
template<class Key , class T , class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
size_type shims::map< Key, T, Compare, Allocator >::size ( void  ) const
inline

Member Data Documentation


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