Classes | Public Types | Public Member Functions | Public Attributes | List of all members
shims::map< Key, T, Compare, Allocator > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/fhiclcpp/v4_06_10/source/fhiclcpp/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

Toperator[] (Key const &key)
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
Tat (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 134 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 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_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 200 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, srt_file_template::find_if, shims::isSnippetMode(), it, findDuplicateFiles::key, shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap, and stan::math::out_of_range().

201  {
202  if (isSnippetMode()) {
203  auto it =
204  std::find_if(_maps.listmap.begin(),
205  _maps.listmap.end(),
206  [&key](auto& element) { return element.first == key; });
207  if (it == _maps.listmap.end())
208  throw std::out_of_range("Key <" + key + "> not found.");
209  return it->second;
210  } else {
211  return _maps.mapmap.at(key);
212  }
213  }
set< int >::iterator it
maps_tuple _maps
Definition: stdmap_shims.h:327
bool isSnippetMode(bool m=false)
void out_of_range(const char *function, int max, int index, const char *msg1="", const char *msg2="")
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 216 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, srt_file_template::find_if, shims::isSnippetMode(), it, findDuplicateFiles::key, shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap, and stan::math::out_of_range().

217  {
218  if (isSnippetMode()) {
219  auto it = std::find_if(
220  _maps.listmap.cbegin(),
221  _maps.listmap.cend(),
222  [&key](auto const& element) { return element.first == key; });
223  if (it == _maps.listmap.cend())
224  throw std::out_of_range("Key <" + key + "> not found.");
225  return it->second;
226  } else {
227  return _maps.mapmap.at(key);
228  }
229  }
set< int >::iterator it
maps_tuple _maps
Definition: stdmap_shims.h:327
bool isSnippetMode(bool m=false)
void out_of_range(const char *function, int max, int index, const char *msg1="", const char *msg2="")
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 163 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.

164  {
165  maps_tuple& maps = *const_cast<maps_tuple*>(&_maps);
166 
167  return isSnippetMode() ? const_iterator{std::begin(maps.listmap)} :
168  const_iterator{std::begin(maps.mapmap)};
169  }
maps_tuple _maps
Definition: stdmap_shims.h:327
iter< iterator_tag, const std::pair< const Key, T >> const_iterator
Definition: stdmap_shims.h:134
bool isSnippetMode(bool m=false)
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 172 of file stdmap_shims.h.

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

173  {
174  return begin();
175  }
iterator begin()
Definition: stdmap_shims.h:156
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 194 of file stdmap_shims.h.

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

195  {
196  return end();
197  }
iterator end()
Definition: stdmap_shims.h:178
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 316 of file stdmap_shims.h.

References shims::map< Key, T, Compare, Allocator >::_maps, make_syst_table_plots::args, shims::isSnippetMode(), shims::map< Key, T, Compare, Allocator >::maps_tuple::listmap, make_pair(), shims::map< Key, T, Compare, Allocator >::maps_tuple::mapmap, prev(), and fillBadChanDBTables::result.

317  {
318  if (isSnippetMode()) {
319  _maps.listmap.emplace_back(std::forward<Args>(args)...);
320  return std::make_pair(iterator{std::prev(_maps.listmap.end())}, true);
321  } else {
322  auto result = _maps.mapmap.emplace(std::forward<Args>(args)...);
323  return std::make_pair(iterator{result.first}, result.second);
324  }
325  }
maps_tuple _maps
Definition: stdmap_shims.h:327
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
bool isSnippetMode(bool m=false)
void prev()
Definition: show_event.C:91
iter< iterator_tag, std::pair< const Key, T >> iterator
Definition: stdmap_shims.h:133
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 ( ) 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 ( )
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 ( ) const
inline

Definition at line 185 of file stdmap_shims.h.

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

186  {
187  maps_tuple& maps = *const_cast<maps_tuple*>(&_maps);
188 
189  return isSnippetMode() ? const_iterator{std::end(maps.listmap)} :
190  const_iterator{std::end(maps.mapmap)};
191  }
maps_tuple _maps
Definition: stdmap_shims.h:327
iter< iterator_tag, const std::pair< const Key, T >> const_iterator
Definition: stdmap_shims.h:134
bool isSnippetMode(bool m=false)
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 260 of file stdmap_shims.h.

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

261  {
262  if (isSnippetMode()) {
263  auto erase_count = size_t{0};
264  auto i = _maps.listmap.begin();
265  auto e = _maps.listmap.end();
266 
267  while (i != e) {
268  if (key == i->first) {
269  i = _maps.listmap.erase(i);
270  ++erase_count;
271  } else {
272  i++;
273  }
274  }
275 
276  return erase_count;
277  } else {
278  return _maps.mapmap.erase(key);
279  }
280  }
maps_tuple _maps
Definition: stdmap_shims.h:327
bool isSnippetMode(bool m=false)
Float_t e
Definition: plot.C:35
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 295 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.

296  {
297  if (isSnippetMode()) {
298  return _maps.listmap.erase(it.get(typename listmap_t::iterator{}));
299  } else {
300  return _maps.mapmap.erase(it.get(typename mapmap_t::iterator{}));
301  }
302  }
set< int >::iterator it
maps_tuple _maps
Definition: stdmap_shims.h:327
bool isSnippetMode(bool m=false)
std::enable_if< std::is_same< typename mapmap_t::iterator, II >::value, II >::type get(II)
Definition: stdmap_shims.h:98
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 305 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.

306  {
307  if (isSnippetMode()) {
308  return _maps.listmap.erase(it.get(typename listmap_t::iterator{}));
309  } else {
310  return _maps.mapmap.erase(it.get(typename mapmap_t::iterator{}));
311  }
312  }
set< int >::iterator it
maps_tuple _maps
Definition: stdmap_shims.h:327
bool isSnippetMode(bool m=false)
std::enable_if< std::is_same< typename mapmap_t::iterator, II >::value, II >::type get(II)
Definition: stdmap_shims.h:98
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 232 of file stdmap_shims.h.

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

233  {
234  if (isSnippetMode()) {
235  return std::find_if(
236  _maps.listmap.begin(), _maps.listmap.end(), [&key](auto& element) {
237  return element.first == key;
238  });
239  } else {
240  return _maps.mapmap.find(key);
241  }
242  }
maps_tuple _maps
Definition: stdmap_shims.h:327
bool isSnippetMode(bool m=false)
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 245 of file stdmap_shims.h.

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

246  {
247  maps_tuple& maps = *const_cast<maps_tuple*>(&_maps);
248 
249  if (isSnippetMode()) {
250  return std::find_if(
251  maps.listmap.begin(),
252  maps.listmap.end(),
253  [&key](auto const& element) { return element.first == key; });
254  } else {
255  return maps.mapmap.find(key);
256  }
257  }
maps_tuple _maps
Definition: stdmap_shims.h:327
bool isSnippetMode(bool m=false)
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 141 of file stdmap_shims.h.

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

142  {
143  if (isSnippetMode()) {
144  for (auto& element : _maps.listmap) {
145  if (element.first == key)
146  return element.second;
147  }
148  _maps.listmap.emplace_back(std::make_pair(key, T{}));
149  return _maps.listmap.back().second;
150  } else {
151  return _maps.mapmap[key];
152  }
153  }
maps_tuple _maps
Definition: stdmap_shims.h:327
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
bool isSnippetMode(bool m=false)
double T
Definition: Xdiff_gwt.C:5
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

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

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