TPIE

2362a60
tpie::tiny::map< Key, T, Comp, Alloc > Class Template Reference

A std::map compatible map, useful when we do not have many elements (less then 512) More...

#include <tpie/tiny.h>

Inherits tpie::tiny::set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp >.

Public Types

typedef std::pair< Key, T > value_type
 
typedef T key_type
 
typedef Inner::iterator iterator
 
typedef Inner::const_iterator const_iterator
 
typedef Inner::reverse_iterator reverse_iterator
 
typedef
Inner::const_reverse_iterator 
const_reverse_iterator
 
typedef Comp key_compare
 
typedef Alloc allocator_type
 
typedef IH::result insert_result
 

Public Member Functions

 map (const Comp &comp, const Alloc &alloc=Alloc())
 
 map (const Alloc &alloc)
 
 map (const map &other)
 
 map (const map &other, const Alloc &alloc)
 
 map (map &&other)
 
 map (map &&other, const Alloc &alloc)
 
template<class InputIterator >
 map (InputIterator first, InputIterator last, const Comp &comp=Comp(), const Alloc &alloc=Alloc())
 
 map (std::initializer_list< typename P::value_type > init, const Comp &comp=Comp(), const Alloc &alloc=Alloc())
 
T & operator[] (const Key &key)
 Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion if such key does not already exist. More...
 
T & operator[] (Key &&key)
 Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion if such key does not already exist. More...
 
T & at (const Key &key)
 Returns a reference to the mapped value of the element with key equivalent to key. More...
 
const T & at (const Key &key) const
 Returns a reference to the mapped value of the element with key equivalent to key. More...
 
iterator begin () noexcept
 Returns an iterator to the first element of the container. More...
 
const_iterator begin () const noexcept
 Returns an iterator to the first element of the container. More...
 
const_iterator cbegin () const noexcept
 Returns an iterator to the first element of the container. More...
 
reverse_iterator rbegin () noexcept
 Returns a reverse iterator to the first element of the reversed container. More...
 
const_reverse_iterator rbegin () const noexcept
 Returns a reverse iterator to the first element of the reversed container. More...
 
const_reverse_iterator crbegin () const noexcept
 Returns a reverse iterator to the first element of the reversed container. More...
 
iterator end () noexcept
 Returns an iterator to the element following the last element of the container. More...
 
const_iterator end () const noexcept
 Returns an iterator to the element following the last element of the container. More...
 
const_iterator cend () const noexcept
 Returns an iterator to the element following the last element of the container. More...
 
reverse_iterator rend () noexcept
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
const_reverse_iterator rend () const noexcept
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
const_reverse_iterator crend () const noexcept
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
bool empty () const noexcept
 Checks if the container has no elements, i.e. More...
 
size_t size () const noexcept
 Returns the number of elements in the container, i.e. More...
 
size_t max_size () const noexcept
 Returns the maximum number of elements the container is able to hold due to system or library implementation limitations. More...
 
void clear ()
 Removes all elements from the container. More...
 
iterator erase (iterator pos)
 Removes the element at pos. More...
 
iterator erase (iterator first, iterator last)
 Removes the elements in the range [first; last), which must be a valid range in *this. More...
 
size_t erase (const T &key)
 Removes all elements with the key value key. More...
 
void swap (set_impl &o)
 Exchanges the contents of the container with those of other. More...
 
iterator find (const T &key) noexcept
 Finds an element with key equivalent to key. More...
 
const_iterator find (const T &key) const noexcept
 Finds an element with key equivalent to key. More...
 
std::pair< iterator, iterator > equal_range (const T &key) noexcept
 Returns a range containing all elements with the given key in the container. More...
 
std::pair< const_iterator,
const_iterator > 
equal_range (const T &key) const noexcept
 Returns a range containing all elements with the given key in the container. More...
 
iterator lower_bound (const T &key) noexcept
 Returns an iterator pointing to the first element that is not less than key. More...
 
const_iterator lower_bound (const T &key) const noexcept
 Returns an iterator pointing to the first element that is not less than key. More...
 
iterator upper_bound (const T &key) noexcept
 Returns an iterator pointing to the first element that is greater than key. More...
 
const_iterator upper_bound (const T &key) const noexcept
 Returns an iterator pointing to the first element that is greater than key. More...
 
key_compare key_comp () const noexcept
 Returns the function object that compares the keys, which is a copy of this container's constructor argument comp. More...
 
value_compare value_comp () const noexcept
 Returns a function object that compares objects of type std::map::value_type (key-value pairs) by using key_comp to compare the first components of the pairs. More...
 
allocator_type get_allocator () const
 Returns the allocator associated with the container. More...
 
size_t count (const Tk) const noexcept
 Returns the number of elements with key k. More...
 
insert_result insert (const std::pair< Key, T > &t)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. More...
 
insert_result insert (TT &&t)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. More...
 
insert_result insert (const_iterator, const std::pair< Key, T > &t)
 Does the same as normal insert, we ignore the hint. More...
 
insert_result insert (const_iterator, TT &&t)
 Does the same as normal insert, we ignore the hint. More...
 
void insert (InputIt first, InputIt last)
 Inserts elements from range [first, last). More...
 
void insert (std::initializer_list< value_type > list)
 Inserts elements from initializer list ilist. More...
 
insert_result emplace (Args &&...args)
 Inserts a new element into the container by constructing it in-place with the given args if there is no element with the key in the container. More...
 
insert_result emplace_hint (const_iterator, Args &&...args)
 Do the same as emplace, and ignore the hint. More...
 
void reserve (size_t new_cap)
 Increase the capacity of the container to a value that's greater or equal to new_cap. More...
 
void shrink_to_fit ()
 Requests the removal of unused capacity. More...
 
size_t capacity () const noexcept
 Returns the number of elements that the container has currently allocated space for. More...
 

Protected Types

typedef std::vector< std::pair
< Key, T >, Alloc > 
Inner
 
typedef
bits::SingleInsertHelp::template
type< Inner > 
IH
 

Protected Attributes

value_compare comp
 
std::vector< value_type, Alloc > inner
 

Detailed Description

template<typename Key, typename T, typename Comp = std::less<Key>, typename Alloc = std::allocator<std::pair<Key, T> >>
class tpie::tiny::map< Key, T, Comp, Alloc >

A std::map compatible map, useful when we do not have many elements (less then 512)

Definition at line 675 of file tiny.h.

Member Function Documentation

template<typename Key , typename T , typename Comp = std::less<Key>, typename Alloc = std::allocator<std::pair<Key, T> >>
T& tpie::tiny::map< Key, T, Comp, Alloc >::at ( const Key &  key)
inline

Returns a reference to the mapped value of the element with key equivalent to key.

If no such element exists, an exception of type std::out_of_range is thrown.

Definition at line 720 of file tiny.h.

References tpie::tiny::set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp >::end(), and tpie::tiny::set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp >::lower_bound().

720  {
721  typename P::iterator x=P::lower_bound(key);
722  if (x == P::end() || P::comp(key, *x)) throw std::out_of_range("tiny::map::at");
723  return x->second;
724  }
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:249
iterator lower_bound(const T &key) noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:387
template<typename Key , typename T , typename Comp = std::less<Key>, typename Alloc = std::allocator<std::pair<Key, T> >>
const T& tpie::tiny::map< Key, T, Comp, Alloc >::at ( const Key &  key) const
inline

Returns a reference to the mapped value of the element with key equivalent to key.

If no such element exists, an exception of type std::out_of_range is thrown.

Definition at line 731 of file tiny.h.

References tpie::tiny::set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp >::end(), and tpie::tiny::set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp >::lower_bound().

731  {
732  typename P::const_iterator x=P::lower_bound(key);
733  if (x == P::end() || P::comp(key, *x)) throw std::out_of_range("tiny::map::at");
734  return x->second;
735  }
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:249
iterator lower_bound(const T &key) noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:387
iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::begin ( )
inlinenoexceptinherited

Returns an iterator to the first element of the container.

Definition at line 219 of file tiny.h.

219 {return inner.begin();}
const_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::begin ( ) const
inlinenoexceptinherited

Returns an iterator to the first element of the container.

Definition at line 224 of file tiny.h.

224 {return inner.cbegin();}
size_t tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::capacity ( ) const
inlinenoexceptinherited

Returns the number of elements that the container has currently allocated space for.

Definition at line 637 of file tiny.h.

637 {return inner.capacity();}
const_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::cbegin ( ) const
inlinenoexceptinherited

Returns an iterator to the first element of the container.

Definition at line 229 of file tiny.h.

229 {return inner.cbegin();}
const_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::cend ( ) const
inlinenoexceptinherited

Returns an iterator to the element following the last element of the container.

Definition at line 259 of file tiny.h.

259 {return inner.cend();}
void tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::clear ( )
inlineinherited

Removes all elements from the container.

Definition at line 300 of file tiny.h.

300 {inner.clear(); }
size_t tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::count ( const T  k) const
inlinenoexceptinherited

Returns the number of elements with key k.

Definition at line 525 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::end(), tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::equal_range(), and tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::lower_bound().

525  {
526  if (IH::multi) {
527  auto x=equal_range(k);
528  return x.second - x.first;
529  } else {
530  auto x=lower_bound(k);
531  if (x == end() || comp(k, *x)) return 0;
532  return 1;
533  }
534  }
std::pair< iterator, iterator > equal_range(const T &key) noexcept
Returns a range containing all elements with the given key in the container.
Definition: tiny.h:369
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:249
iterator lower_bound(const T &key) noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:387
const_reverse_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::crbegin ( ) const
inlinenoexceptinherited

Returns a reverse iterator to the first element of the reversed container.

Definition at line 244 of file tiny.h.

244 {return inner.rbegin();}
const_reverse_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::crend ( ) const
inlinenoexceptinherited

Returns a reverse iterator to the element following the last element of the reversed container.

Definition at line 277 of file tiny.h.

277 {return inner.rend();}
insert_result tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::emplace ( Args &&...  args)
inlineinherited

Inserts a new element into the container by constructing it in-place with the given args if there is no element with the key in the container.

Returns
Returns a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a bool denoting whether the insertion took place.

Definition at line 607 of file tiny.h.

Referenced by tpie::tiny::map< Key, T, Comp, Alloc >::operator[]().

607  {
608  inner.emplace_back(std::forward<Args>(args)...);
609  return IH::handle(inner, comp);
610  }
insert_result tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::emplace_hint ( const_iterator  ,
Args &&...  args 
)
inlineinherited

Do the same as emplace, and ignore the hint.

Definition at line 616 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::emplace().

616  {
617  return emplace(std::forward<Args>(args)...);
618  }
insert_result emplace(Args &&...args)
Inserts a new element into the container by constructing it in-place with the given args if there is ...
Definition: tiny.h:607
bool tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::empty ( ) const
inlinenoexceptinherited

Checks if the container has no elements, i.e.

whether begin() == end().

Definition at line 283 of file tiny.h.

283 {return inner.empty();}
iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::end ( )
inlinenoexceptinherited

Returns an iterator to the element following the last element of the container.

Definition at line 249 of file tiny.h.

Referenced by tpie::tiny::map< Key, T, Comp, Alloc >::at().

249 {return inner.end();}
const_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::end ( ) const
inlinenoexceptinherited

Returns an iterator to the element following the last element of the container.

Definition at line 254 of file tiny.h.

254 {return inner.cend();}
std::pair<iterator, iterator> tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::equal_range ( const T &  key)
inlinenoexceptinherited

Returns a range containing all elements with the given key in the container.

The range is defined by two iterators, one pointing to the first element that is not less than key and another pointing to the first element greater than key.

Definition at line 369 of file tiny.h.

369  {
370  return std::equal_range(inner.begin(), inner.end(), key, comp);
371  }
std::pair<const_iterator, const_iterator> tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::equal_range ( const T &  key) const
inlinenoexceptinherited

Returns a range containing all elements with the given key in the container.

The range is defined by two iterators, one pointing to the first element that is not less than key and another pointing to the first element greater than key.

Definition at line 379 of file tiny.h.

379  {
380  return std::equal_range(inner.begin(), inner.end(), key, comp);
381  }
iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::erase ( iterator  pos)
inlineinherited

Removes the element at pos.

Returns
Iterator following the last removed element.

Definition at line 306 of file tiny.h.

306  {
307  std::rotate(pos, std::next(pos), inner.end());
308  inner.pop_back();
309  return pos;
310  }
iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::erase ( iterator  first,
iterator  last 
)
inlineinherited

Removes the elements in the range [first; last), which must be a valid range in *this.

Returns
Iterator following the last removed element.

Definition at line 317 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::begin(), and tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::size().

317  {
318  std::rotate(first, last, inner.end());
319  inner.resize(size() - (last-first));
320  return begin();
321  }
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: tiny.h:219
size_t size() const noexcept
Returns the number of elements in the container, i.e.
Definition: tiny.h:288
size_t tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::erase ( const T &  key)
inlineinherited

Removes all elements with the key value key.

Returns
Number of elements removed.

Definition at line 327 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::equal_range(), and tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::erase().

327  {
328  auto x=equal_range(key);
329  erase(x.first, x.second);
330  return x.second - x.first;
331  }
std::pair< iterator, iterator > equal_range(const T &key) noexcept
Returns a range containing all elements with the given key in the container.
Definition: tiny.h:369
iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::find ( const T &  key)
inlinenoexceptinherited

Finds an element with key equivalent to key.

If no such element is found, past-the-end iterator is returned.

Definition at line 347 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::end(), and tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::lower_bound().

347  {
348  iterator x=lower_bound(key);
349  if (x == end() || comp(key, *x)) return end();
350  return x;
351  }
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:249
iterator lower_bound(const T &key) noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:387
const_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::find ( const T &  key) const
inlinenoexceptinherited

Finds an element with key equivalent to key.

If no such element is found, past-the-end iterator is returned.

Definition at line 357 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::end(), and tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::lower_bound().

357  {
358  const_iterator x=lower_bound(key);
359  if (x == end() || comp(key, *x)) return end();
360  return x;
361  }
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:249
iterator lower_bound(const T &key) noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:387
allocator_type tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::get_allocator ( ) const
inlineinherited

Returns the allocator associated with the container.

Definition at line 435 of file tiny.h.

435  {
436  return inner.get_allocator();
437  }
insert_result tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::insert ( const std::pair< Key, T > &  t)
inlineinherited

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Returns
Returns a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 545 of file tiny.h.

545  {
546  inner.push_back(t);
547  return IH::handle(inner, comp);
548  }
insert_result tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::insert ( TT &&  t)
inlineinherited

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Returns
Returns a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 560 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::emplace().

560  {
561  return emplace(std::forward<TT>(t));
562  }
insert_result emplace(Args &&...args)
Inserts a new element into the container by constructing it in-place with the given args if there is ...
Definition: tiny.h:607
insert_result tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::insert ( const_iterator  ,
const std::pair< Key, T > &  t 
)
inlineinherited

Does the same as normal insert, we ignore the hint.

Definition at line 567 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::insert().

567  {
568  return insert(t);
569  }
insert_result insert(const std::pair< Key, T > &t)
Inserts element(s) into the container, if the container doesn't already contain an element with an eq...
Definition: tiny.h:545
insert_result tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::insert ( const_iterator  ,
TT &&  t 
)
inlineinherited

Does the same as normal insert, we ignore the hint.

Definition at line 575 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::insert().

575  {
576  return insert(std::forward<TT>(t));
577  }
insert_result insert(const std::pair< Key, T > &t)
Inserts element(s) into the container, if the container doesn't already contain an element with an eq...
Definition: tiny.h:545
void tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::insert ( InputIt  first,
InputIt  last 
)
inlineinherited

Inserts elements from range [first, last).

Definition at line 583 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::insert(), and tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::size().

583  {
584  inner.reserve(size() + last-first);
585  for (InputIt i=first; i != last; ++i)
586  insert(*i);
587  }
size_t size() const noexcept
Returns the number of elements in the container, i.e.
Definition: tiny.h:288
insert_result insert(const std::pair< Key, T > &t)
Inserts element(s) into the container, if the container doesn't already contain an element with an eq...
Definition: tiny.h:545
void tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::insert ( std::initializer_list< value_type >  list)
inlineinherited

Inserts elements from initializer list ilist.

Definition at line 592 of file tiny.h.

References tpie::tiny::set_impl< T, Key, KeyExtract, Comp, Alloc, InsertHelp >::insert().

592  {
593  insert(list.begin(), list.end());
594  }
insert_result insert(const std::pair< Key, T > &t)
Inserts element(s) into the container, if the container doesn't already contain an element with an eq...
Definition: tiny.h:545
key_compare tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::key_comp ( ) const
inlinenoexceptinherited

Returns the function object that compares the keys, which is a copy of this container's constructor argument comp.

Definition at line 419 of file tiny.h.

419  {
420  return comp.comp;
421  }
iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::lower_bound ( const T &  key)
inlinenoexceptinherited

Returns an iterator pointing to the first element that is not less than key.

Definition at line 387 of file tiny.h.

Referenced by tpie::tiny::map< Key, T, Comp, Alloc >::at().

387  {
388  return std::lower_bound(inner.begin(), inner.end(), key, comp);
389  }
const_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::lower_bound ( const T &  key) const
inlinenoexceptinherited

Returns an iterator pointing to the first element that is not less than key.

Definition at line 395 of file tiny.h.

395  {
396  return std::lower_bound(inner.begin(), inner.end(), key, comp);
397  }
size_t tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::max_size ( ) const
inlinenoexceptinherited

Returns the maximum number of elements the container is able to hold due to system or library implementation limitations.

Definition at line 295 of file tiny.h.

295 {return inner.max_size();}
template<typename Key , typename T , typename Comp = std::less<Key>, typename Alloc = std::allocator<std::pair<Key, T> >>
T& tpie::tiny::map< Key, T, Comp, Alloc >::operator[] ( const Key &  key)
inline

Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion if such key does not already exist.

Definition at line 702 of file tiny.h.

References tpie::tiny::set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp >::emplace().

702  {
703  return this->emplace(key, T()).first->second;
704  }
insert_result emplace(Args &&...args)
Inserts a new element into the container by constructing it in-place with the given args if there is ...
Definition: tiny.h:607
template<typename Key , typename T , typename Comp = std::less<Key>, typename Alloc = std::allocator<std::pair<Key, T> >>
T& tpie::tiny::map< Key, T, Comp, Alloc >::operator[] ( Key &&  key)
inline

Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion if such key does not already exist.

Definition at line 711 of file tiny.h.

References tpie::tiny::set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp >::emplace().

711  {
712  return this->emplace(std::move(key), T()).first->second;
713  }
insert_result emplace(Args &&...args)
Inserts a new element into the container by constructing it in-place with the given args if there is ...
Definition: tiny.h:607
reverse_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::rbegin ( )
inlinenoexceptinherited

Returns a reverse iterator to the first element of the reversed container.

Definition at line 234 of file tiny.h.

234 {return inner.rbegin();}
const_reverse_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::rbegin ( ) const
inlinenoexceptinherited

Returns a reverse iterator to the first element of the reversed container.

Definition at line 239 of file tiny.h.

239 {return inner.rbegin();}
reverse_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::rend ( )
inlinenoexceptinherited

Returns a reverse iterator to the element following the last element of the reversed container.

Definition at line 265 of file tiny.h.

265 {return inner.rend();}
const_reverse_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::rend ( ) const
inlinenoexceptinherited

Returns a reverse iterator to the element following the last element of the reversed container.

Definition at line 271 of file tiny.h.

271 {return inner.rend();}
void tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::reserve ( size_t  new_cap)
inlineinherited

Increase the capacity of the container to a value that's greater or equal to new_cap.

If new_cap is greater than the current capacity(), new storage is allocated, otherwise the method does nothing.

Definition at line 626 of file tiny.h.

626 {inner.reserve(new_cap);}
void tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::shrink_to_fit ( )
inlineinherited

Requests the removal of unused capacity.

Definition at line 631 of file tiny.h.

631 {inner.shrink_to_fit();}
size_t tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::size ( ) const
inlinenoexceptinherited

Returns the number of elements in the container, i.e.

std::distance(begin(), end())

Definition at line 288 of file tiny.h.

288 {return inner.size();}
void tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::swap ( set_impl< std::pair< Key, T >, T, bits::PairExtract< Key, T >, Comp, Alloc, bits::SingleInsertHelp > &  o)
inlineinherited

Exchanges the contents of the container with those of other.

Does not invoke any move, copy, or swap operations on individual elements.

Definition at line 338 of file tiny.h.

338  {
339  std::swap(comp, o.comp);
340  std::swap(inner, o.inner);
341  }
iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::upper_bound ( const T &  key)
inlinenoexceptinherited

Returns an iterator pointing to the first element that is greater than key.

Definition at line 403 of file tiny.h.

403  {
404  return std::upper_bound(inner.begin(), inner.end(), key, comp);
405  }
const_iterator tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::upper_bound ( const T &  key) const
inlinenoexceptinherited

Returns an iterator pointing to the first element that is greater than key.

Definition at line 411 of file tiny.h.

411  {
412  return std::upper_bound(inner.begin(), inner.end(), key, comp);
413  }
value_compare tpie::tiny::set_impl< std::pair< Key, T > , T , bits::PairExtract< Key, T > , Comp, Alloc, bits::SingleInsertHelp >::value_comp ( ) const
inlinenoexceptinherited

Returns a function object that compares objects of type std::map::value_type (key-value pairs) by using key_comp to compare the first components of the pairs.

Definition at line 428 of file tiny.h.

428  {
429  return comp;
430  }

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