Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
cet::map_vector< Value > Class Template Reference

#include <map_vector.h>

Public Types

using key_type = map_vector_key
 
using mapped_type = Value
 
using value_type = std::pair< key_type, mapped_type >
 
using impl_type = std::vector< value_type >
 
using size_type = typename impl_type::size_type
 
using difference_type = typename impl_type::difference_type
 
using iterator = typename impl_type::iterator
 
using const_iterator = typename impl_type::const_iterator
 
using reverse_iterator = typename impl_type::reverse_iterator
 
using const_reverse_iterator = typename impl_type::const_reverse_iterator
 
using allocator_type = typename impl_type::allocator_type
 
using pointer = typename allocator_type::pointer
 
using const_pointer = typename allocator_type::const_pointer
 
using reference = typename allocator_type::reference
 
using const_reference = typename allocator_type::const_reference
 

Public Member Functions

 map_vector ()=default
 
template<class InIter >
 map_vector (InIter const b, InIter const e)
 
bool empty () const noexcept
 
size_type size () const noexcept
 
size_type max_size () const noexcept
 
size_type capacity () const noexcept
 
allocator_type get_allocator () const noexcept
 
value_type const & front () const
 
value_type const & back () const
 
size_t delta () const
 
bool has (key_type key) const
 
iterator find (key_type key)
 
const_iterator find (key_type key) const
 
const_iterator findOrThrow (key_type key) const
 
mapped_typegetOrNull (key_type key)
 
mapped_type const * getOrNull (key_type key) const
 
mapped_typegetOrThrow (key_type key)
 
mapped_type const & getOrThrow (key_type key) const
 
mapped_typeoperator[] (key_type key)
 
mapped_type const & operator[] (key_type key) const
 
mapped_type const & at (key_type key) const
 
iterator begin () noexcept
 
const_iterator begin () const noexcept
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
reverse_iterator rbegin () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator rend () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const noexcept
 
void clear () noexcept
 
void reserve (size_type const n)
 
void swap (map_vector< mapped_type > &other)
 
std::pair< iterator, boolinsert (value_type const &x)
 
template<class InIter >
void insert (InIter b, InIter e)
 
template<class InIter >
void append (InIter b, InIter e)
 

Static Public Member Functions

static short Class_Version ()
 

Private Member Functions

bool class_invariant () const
 

Static Private Member Functions

static bool lt (value_type const &, value_type const &) noexcept
 
static bool eq (value_type const &, value_type const &) noexcept
 

Private Attributes

impl_type v_ {}
 

Detailed Description

template<class Value>
class cet::map_vector< Value >

Definition at line 29 of file map_vector.h.

Member Typedef Documentation

template<class Value>
using cet::map_vector< Value >::allocator_type = typename impl_type::allocator_type

Definition at line 100 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::const_iterator = typename impl_type::const_iterator

Definition at line 96 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::const_pointer = typename allocator_type::const_pointer

Definition at line 102 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::const_reference = typename allocator_type::const_reference

Definition at line 104 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::const_reverse_iterator = typename impl_type::const_reverse_iterator

Definition at line 98 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::difference_type = typename impl_type::difference_type

Definition at line 93 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::impl_type = std::vector<value_type>

Definition at line 90 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::iterator = typename impl_type::iterator

Definition at line 95 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::key_type = map_vector_key

Definition at line 87 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::mapped_type = Value

Definition at line 88 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::pointer = typename allocator_type::pointer

Definition at line 101 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::reference = typename allocator_type::reference

Definition at line 103 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::reverse_iterator = typename impl_type::reverse_iterator

Definition at line 97 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::size_type = typename impl_type::size_type

Definition at line 92 of file map_vector.h.

template<class Value>
using cet::map_vector< Value >::value_type = std::pair<key_type, mapped_type>

Definition at line 89 of file map_vector.h.

Constructor & Destructor Documentation

template<class Value>
cet::map_vector< Value >::map_vector ( )
default
template<class Value>
template<class InIter >
cet::map_vector< Value >::map_vector ( InIter const  b,
InIter const  e 
)
inline

Definition at line 110 of file map_vector.h.

111  {
112  insert(b, e);
113  }
std::pair< iterator, bool > insert(value_type const &x)
Definition: map_vector.h:471
const double e
static bool * b
Definition: config.cpp:1043

Member Function Documentation

template<class Value >
template<class InIter >
void cet::map_vector< Value >::append ( InIter  b,
InIter  e 
)

Definition at line 499 of file map_vector.h.

500 {
501  std::for_each(b, e, [](auto const& pr) { return pr.first.ensure_valid(); });
502  v_.insert(v_.cend(), b, e);
503  assert(class_invariant());
504 }
const double e
impl_type v_
Definition: map_vector.h:287
bool class_invariant() const
Definition: map_vector.h:511
static bool * b
Definition: config.cpp:1043
template<class Value>
mapped_type const& cet::map_vector< Value >::at ( key_type  key) const
inline

Definition at line 172 of file map_vector.h.

173  {
174  return getOrThrow(key);
175  }
def key(type, name=None)
Definition: graph.py:13
mapped_type & getOrThrow(key_type key)
Definition: map_vector.h:433
template<class Value >
cet::map_vector< Value >::value_type const & cet::map_vector< Value >::back ( ) const

Definition at line 364 of file map_vector.h.

365 {
366  if (v_.empty())
367  throw cet::exception("map_vector::back") << "container is empty!\n";
368  return v_.back();
369 }
impl_type v_
Definition: map_vector.h:287
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class Value>
iterator cet::map_vector< Value >::begin ( )
inlinenoexcept

Definition at line 179 of file map_vector.h.

180  {
181  return v_.begin();
182  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_iterator cet::map_vector< Value >::begin ( ) const
inlinenoexcept

Definition at line 184 of file map_vector.h.

185  {
186  return v_.begin();
187  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
size_type cet::map_vector< Value >::capacity ( ) const
inlinenoexcept

Definition at line 134 of file map_vector.h.

135  {
136  return v_.capacity();
137  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_iterator cet::map_vector< Value >::cbegin ( ) const
inlinenoexcept

Definition at line 223 of file map_vector.h.

224  {
225  return v_.cbegin();
226  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_iterator cet::map_vector< Value >::cend ( ) const
inlinenoexcept

Definition at line 228 of file map_vector.h.

229  {
230  return v_.cend();
231  }
impl_type v_
Definition: map_vector.h:287
template<class Value >
bool cet::map_vector< Value >::class_invariant ( ) const
private

Definition at line 511 of file map_vector.h.

512 {
513  return std::is_sorted(v_.begin(), v_.end(), lt);
514 }
static bool lt(value_type const &, value_type const &) noexcept
Definition: map_vector.h:520
impl_type v_
Definition: map_vector.h:287
template<class Value>
static short cet::map_vector< Value >::Class_Version ( )
inlinestatic

Definition at line 281 of file map_vector.h.

282  {
283  return 10;
284  }
template<class Value>
void cet::map_vector< Value >::clear ( )
inlinenoexcept

Definition at line 245 of file map_vector.h.

246  {
247  v_.clear();
248  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_reverse_iterator cet::map_vector< Value >::crbegin ( ) const
inline

Definition at line 233 of file map_vector.h.

234  {
235  return v_.crbegin();
236  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_reverse_iterator cet::map_vector< Value >::crend ( ) const
inlinenoexcept

Definition at line 238 of file map_vector.h.

239  {
240  return v_.crend();
241  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
size_t cet::map_vector< Value >::delta ( ) const
inline

Definition at line 152 of file map_vector.h.

153  {
154  return v_.empty() ? 0 : 1 + v_.back().first.asInt();
155  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
bool cet::map_vector< Value >::empty ( ) const
inlinenoexcept

Definition at line 119 of file map_vector.h.

120  {
121  return v_.empty();
122  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
iterator cet::map_vector< Value >::end ( )
inlinenoexcept

Definition at line 190 of file map_vector.h.

191  {
192  return v_.end();
193  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_iterator cet::map_vector< Value >::end ( ) const
inlinenoexcept

Definition at line 195 of file map_vector.h.

196  {
197  return v_.end();
198  }
impl_type v_
Definition: map_vector.h:287
template<class Value >
bool cet::map_vector< Value >::eq ( value_type const &  v1,
value_type const &  v2 
)
staticprivatenoexcept

Definition at line 527 of file map_vector.h.

528 {
529  return v1.first == v2.first;
530 }
template<class Value >
cet::map_vector< Value >::iterator cet::map_vector< Value >::find ( key_type  key)

Definition at line 381 of file map_vector.h.

382 {
383  value_type const v{key, mapped_type{}};
384  auto const begin = v_.begin(), end = v_.end();
385  auto it = std::lower_bound(begin, end, v, lt);
386  if (it != end && it->first != key)
387  it = end;
388  return it;
389 }
std::pair< key_type, mapped_type > value_type
Definition: map_vector.h:89
iterator end() noexcept
Definition: map_vector.h:190
Value mapped_type
Definition: map_vector.h:88
static bool lt(value_type const &, value_type const &) noexcept
Definition: map_vector.h:520
def key(type, name=None)
Definition: graph.py:13
impl_type v_
Definition: map_vector.h:287
iterator begin() noexcept
Definition: map_vector.h:179
template<class Value >
cet::map_vector< Value >::const_iterator cet::map_vector< Value >::find ( key_type  key) const

Definition at line 393 of file map_vector.h.

394 {
395  value_type const v{key, mapped_type{}};
396  auto const begin = v_.cbegin(), end = v_.cend();
397  auto it = std::lower_bound(begin, end, v, lt);
398  if (it != end && it->first != key)
399  it = end;
400  return it;
401 }
std::pair< key_type, mapped_type > value_type
Definition: map_vector.h:89
iterator end() noexcept
Definition: map_vector.h:190
Value mapped_type
Definition: map_vector.h:88
static bool lt(value_type const &, value_type const &) noexcept
Definition: map_vector.h:520
def key(type, name=None)
Definition: graph.py:13
impl_type v_
Definition: map_vector.h:287
iterator begin() noexcept
Definition: map_vector.h:179
template<class Value >
cet::map_vector< Value >::const_iterator cet::map_vector< Value >::findOrThrow ( key_type  key) const

Definition at line 405 of file map_vector.h.

406 {
407  auto p = find(key);
408  if (p == v_.cend())
409  throw cet::exception("map_vector::getOrThrow")
410  << "out of range (no such key): " << key.asInt() << std::endl;
411 
412  return p;
413 }
iterator find(key_type key)
Definition: map_vector.h:381
def key(type, name=None)
Definition: graph.py:13
impl_type v_
Definition: map_vector.h:287
p
Definition: test.py:223
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
template<class Value >
cet::map_vector< Value >::value_type const & cet::map_vector< Value >::front ( ) const

Definition at line 355 of file map_vector.h.

356 {
357  if (v_.empty())
358  throw cet::exception("map_vector::front") << "container is empty!\n";
359  return v_.front();
360 }
impl_type v_
Definition: map_vector.h:287
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class Value>
allocator_type cet::map_vector< Value >::get_allocator ( ) const
inlinenoexcept

Definition at line 140 of file map_vector.h.

141  {
142  return v_.get_allocator();
143  }
impl_type v_
Definition: map_vector.h:287
template<class Value >
Value * cet::map_vector< Value >::getOrNull ( key_type  key)

Definition at line 417 of file map_vector.h.

418 {
419  auto it = find(key);
420  return it == v_.end() ? nullptr : &it->second;
421 }
iterator find(key_type key)
Definition: map_vector.h:381
def key(type, name=None)
Definition: graph.py:13
impl_type v_
Definition: map_vector.h:287
template<class Value >
Value const * cet::map_vector< Value >::getOrNull ( key_type  key) const

Definition at line 425 of file map_vector.h.

426 {
427  auto it = find(key);
428  return it == v_.cend() ? nullptr : &it->second;
429 }
iterator find(key_type key)
Definition: map_vector.h:381
def key(type, name=None)
Definition: graph.py:13
impl_type v_
Definition: map_vector.h:287
template<class Value >
Value & cet::map_vector< Value >::getOrThrow ( key_type  key)

Definition at line 433 of file map_vector.h.

434 {
435  auto* p = getOrNull(key);
436  if (p == nullptr)
437  throw cet::exception("map_vector::getOrThrow")
438  << "out of range (no such key): " << key.asInt() << std::endl;
439 
440  return *p;
441 }
def key(type, name=None)
Definition: graph.py:13
p
Definition: test.py:223
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
mapped_type * getOrNull(key_type key)
Definition: map_vector.h:417
template<class Value >
Value const & cet::map_vector< Value >::getOrThrow ( key_type  key) const

Definition at line 445 of file map_vector.h.

446 {
447  auto const* p = getOrNull(key);
448  if (p == nullptr)
449  throw cet::exception("map_vector::getOrThrow")
450  << "out of range (no such key): " << key.asInt() << std::endl;
451 
452  return *p;
453 }
def key(type, name=None)
Definition: graph.py:13
p
Definition: test.py:223
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
mapped_type * getOrNull(key_type key)
Definition: map_vector.h:417
template<class Value >
bool cet::map_vector< Value >::has ( key_type  key) const

Definition at line 373 of file map_vector.h.

374 {
375  value_type const v{key, mapped_type{}};
376  return std::binary_search(v_.begin(), v_.end(), v, lt);
377 }
std::pair< key_type, mapped_type > value_type
Definition: map_vector.h:89
Value mapped_type
Definition: map_vector.h:88
static bool lt(value_type const &, value_type const &) noexcept
Definition: map_vector.h:520
def key(type, name=None)
Definition: graph.py:13
impl_type v_
Definition: map_vector.h:287
template<class Value >
std::pair< typename cet::map_vector< Value >::iterator, bool > cet::map_vector< Value >::insert ( value_type const &  x)

Definition at line 471 of file map_vector.h.

472 {
473  v.first.ensure_valid();
474  auto const begin = v_.begin(), end = v_.end();
475  auto it = std::lower_bound(begin, end, v, lt);
476  if (it == end || it->first != v.first)
477  return std::make_pair(v_.insert(it, v), true);
478  return std::make_pair(it, false);
479 }
iterator end() noexcept
Definition: map_vector.h:190
static bool lt(value_type const &, value_type const &) noexcept
Definition: map_vector.h:520
impl_type v_
Definition: map_vector.h:287
iterator begin() noexcept
Definition: map_vector.h:179
template<class Value >
template<class InIter >
void cet::map_vector< Value >::insert ( InIter  b,
InIter  e 
)

Definition at line 484 of file map_vector.h.

485 {
486  std::for_each(b, e, [](auto const& pr) { return pr.first.ensure_valid(); });
488  result.reserve(size() + std::distance(b, e));
489  std::merge(v_.cbegin(), v_.cend(), b, e, back_inserter(result), lt);
490  auto new_end = std::unique(result.begin(), result.end(), eq);
491  result.erase(new_end, result.end());
492  result.shrink_to_fit();
493  v_.swap(result);
494 }
static QCString result
std::vector< value_type > impl_type
Definition: map_vector.h:90
static bool lt(value_type const &, value_type const &) noexcept
Definition: map_vector.h:520
const double e
impl_type v_
Definition: map_vector.h:287
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static bool * b
Definition: config.cpp:1043
static bool eq(value_type const &, value_type const &) noexcept
Definition: map_vector.h:527
size_type size() const noexcept
Definition: map_vector.h:124
template<class Value >
bool cet::map_vector< Value >::lt ( value_type const &  v1,
value_type const &  v2 
)
staticprivatenoexcept

Definition at line 520 of file map_vector.h.

521 {
522  return v1.first < v2.first;
523 }
template<class Value>
size_type cet::map_vector< Value >::max_size ( ) const
inlinenoexcept

Definition at line 129 of file map_vector.h.

130  {
131  return v_.max_size();
132  }
impl_type v_
Definition: map_vector.h:287
template<class Value >
Value & cet::map_vector< Value >::operator[] ( key_type  key)

Definition at line 456 of file map_vector.h.

457 {
458  value_type const v{key, mapped_type{}};
459  auto const begin = v_.begin(), end = v_.end();
460  auto it = std::lower_bound(begin, end, v, lt);
461  if (it == end || it->first != key)
462  it = v_.insert(it, std::move(v));
463  return it->second;
464 }
std::pair< key_type, mapped_type > value_type
Definition: map_vector.h:89
iterator end() noexcept
Definition: map_vector.h:190
Value mapped_type
Definition: map_vector.h:88
static bool lt(value_type const &, value_type const &) noexcept
Definition: map_vector.h:520
def key(type, name=None)
Definition: graph.py:13
def move(depos, offset)
Definition: depos.py:107
impl_type v_
Definition: map_vector.h:287
iterator begin() noexcept
Definition: map_vector.h:179
template<class Value>
mapped_type const& cet::map_vector< Value >::operator[] ( key_type  key) const
inline

Definition at line 170 of file map_vector.h.

170 { return getOrThrow(key); }
def key(type, name=None)
Definition: graph.py:13
mapped_type & getOrThrow(key_type key)
Definition: map_vector.h:433
template<class Value>
reverse_iterator cet::map_vector< Value >::rbegin ( )
inlinenoexcept

Definition at line 201 of file map_vector.h.

202  {
203  return v_.rbegin();
204  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_reverse_iterator cet::map_vector< Value >::rbegin ( ) const
inlinenoexcept

Definition at line 206 of file map_vector.h.

207  {
208  return v_.rbegin();
209  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
reverse_iterator cet::map_vector< Value >::rend ( )
inlinenoexcept

Definition at line 212 of file map_vector.h.

213  {
214  return v_.rend();
215  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
const_reverse_iterator cet::map_vector< Value >::rend ( ) const
inlinenoexcept

Definition at line 217 of file map_vector.h.

218  {
219  return v_.rend();
220  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
void cet::map_vector< Value >::reserve ( size_type const  n)
inline

Definition at line 251 of file map_vector.h.

252  {
253  v_.reserve(n);
254  }
std::void_t< T > n
impl_type v_
Definition: map_vector.h:287
template<class Value>
size_type cet::map_vector< Value >::size ( ) const
inlinenoexcept

Definition at line 124 of file map_vector.h.

125  {
126  return v_.size();
127  }
impl_type v_
Definition: map_vector.h:287
template<class Value>
void cet::map_vector< Value >::swap ( map_vector< mapped_type > &  other)
inline

Definition at line 257 of file map_vector.h.

258  {
259  v_.swap(other.v_);
260  }
impl_type v_
Definition: map_vector.h:287

Member Data Documentation

template<class Value>
impl_type cet::map_vector< Value >::v_ {}
private

Definition at line 287 of file map_vector.h.


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