TPIE

11a2c2d
tiny.h
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2015, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 #ifndef __TPIE_TINY_H__
20 #define __TPIE_TINY_H__
21 
22 #include <algorithm>
23 #include <stdexcept>
24 #include <tpie/config.h>
25 
26 namespace tpie {
27 namespace tiny {
28 
35 template <typename T, typename Comp>
36 void sort(T start, T end, Comp comp=Comp()) {
37  for (T i = start; i != end; ++i)
38  std::rotate(std::upper_bound(start, i, *i, comp), i, std::next(i));
39 }
40 
47 template <typename T>
48 void sort(T start, T end) {
49  for (T i = start; i != end; ++i)
50  std::rotate(std::upper_bound(start, i, *i), i, std::next(i));
51 }
52 
53 namespace bits {
58 public:
59  template <typename T>
60  const T & operator()(const T & x) const {return x;}
61 };
62 
66 template <typename A, typename B>
67 class PairExtract {
68 public:
69  template <typename T>
70  const T & operator()(const T & x) const {return x;}
71  const A & operator()(const std::pair<A, B> & x) const {return x.first;}
72 };
73 
78  template <typename Inner>
79  struct type {
80  static const bool multi=false;
81  typedef typename Inner::iterator iterator;
82  typedef std::pair<iterator, bool> result;
83 
84  template <typename Comp>
85  static result handle(Inner & inner, const Comp & comp) {
86  iterator fend=std::prev(inner.end());
87  iterator i=std::lower_bound(inner.begin(), fend, *fend, comp);
88  if (i != fend && !comp(*fend, *i)) {
89  inner.pop_back();
90  return std::make_pair(i, false);
91  }
92  std::rotate(i, fend, std::next(fend));
93  return std::make_pair(i, true);
94  }
95  };
96 };
97 
102  template <typename Inner>
103  struct type {
104  static const bool multi=true;
105  typedef typename Inner::iterator iterator;
106  typedef iterator result;
107 
108  template <typename Comp>
109  static result handle(Inner & inner, const Comp &) {
110  iterator y=std::upper_bound(inner.begin(), inner.end()-1, inner.back());
111  std::rotate(y, inner.end()-1, inner.end());
112  return y;
113  }
114  };
115 };
116 
117 } //namespace bits
131 template <typename T,
132  typename Key,
133  typename KeyExtract,
134  typename Comp,
135  typename Alloc,
136  typename InsertHelp>
137 class set_impl {
138 protected:
139  typedef std::vector<T, Alloc> Inner;
140  typedef typename InsertHelp::template type<Inner> IH;
141 public:
142  typedef T value_type;
143  typedef Key key_type;
144  typedef typename Inner::iterator iterator;
145  typedef typename Inner::const_iterator const_iterator;
146  typedef typename Inner::reverse_iterator reverse_iterator;
147  typedef typename Inner::const_reverse_iterator const_reverse_iterator;
148  typedef Comp key_compare;
149  typedef Alloc allocator_type;
150  typedef typename IH::result insert_result;
151 
152  struct value_compare {
153  template <typename L, typename R>
154  bool operator()(const L & l, const R & r) const {
155  return comp(extract(l), extract(r));
156  }
157  Comp comp;
158  KeyExtract extract;
159  value_compare(Comp comp): comp(comp) {}
160  };
161 
165  set_impl(): comp(Comp()) {}
166 
170  explicit set_impl(const Comp & comp, const Alloc & alloc=Alloc()): comp(comp), inner(alloc) {}
171 
175  explicit set_impl(const Alloc & alloc): inner(alloc) {}
176 
180  set_impl(const set_impl & other): comp(other.comp), inner(other.inner) {}
181 
185  set_impl(const set_impl & other, const Alloc & alloc): comp(other.comp), inner(other.inner, alloc) {}
186 
190  set_impl(set_impl && other): comp(std::move(other.comp)), inner(std::move(other.inner)) {}
191 
195  set_impl(set_impl && other, const Alloc & alloc): comp(std::move(other.comp)), inner(std::move(other.inner), alloc) {}
196 
200  template< class InputIterator >
201  set_impl(InputIterator first, InputIterator last,
202  const Comp& comp = Comp(),
203  const Alloc& alloc = Alloc()): comp(comp), inner(alloc) {
204  insert(first, last);
205  }
206 
210  set_impl( std::initializer_list<value_type> init,
211  const Comp& comp = Comp(),
212  const Alloc& alloc = Alloc() ): comp(comp), inner(alloc) {
213  insert(init);
214  }
215 
219  iterator begin() noexcept {return inner.begin();}
220 
224  const_iterator begin() const noexcept {return inner.cbegin();}
225 
229  const_iterator cbegin() const noexcept {return inner.cbegin();}
230 
234  reverse_iterator rbegin() noexcept {return inner.rbegin();}
235 
239  const_reverse_iterator rbegin() const noexcept {return inner.rbegin();}
240 
244  const_reverse_iterator crbegin() const noexcept {return inner.rbegin();}
245 
249  iterator end() noexcept {return inner.end();}
250 
254  const_iterator end() const noexcept {return inner.cend();}
255 
259  const_iterator cend() const noexcept {return inner.cend();}
260 
265  reverse_iterator rend() noexcept {return inner.rend();}
266 
271  const_reverse_iterator rend() const noexcept {return inner.rend();}
272 
277  const_reverse_iterator crend() const noexcept {return inner.rend();}
278 
283  bool empty() const noexcept {return inner.empty();}
284 
288  size_t size() const noexcept {return inner.size();}
289 
295  size_t max_size() const noexcept {return inner.max_size();}
296 
300  void clear() {inner.clear(); }
301 
306  iterator erase(iterator pos) {
307  std::rotate(pos, std::next(pos), inner.end());
308  inner.pop_back();
309  return pos;
310  }
311 
317  iterator erase(iterator first, iterator last) {
318  std::rotate(first, last, inner.end());
319  inner.resize(size() - (last-first));
320  return begin();
321  }
322 
327  size_t erase(const Key & key) {
328  auto x=equal_range(key);
329  auto res = x.second - x.first;
330  erase(x.first, x.second);
331  return res;
332  }
333 
339  void swap(set_impl & o) {
340  std::swap(comp, o.comp);
341  std::swap(inner, o.inner);
342  }
343 
348  iterator find(const Key & key) noexcept {
349  iterator x=lower_bound(key);
350  if (x == end() || comp(key, *x)) return end();
351  return x;
352  }
353 
358  const_iterator find(const Key & key) const noexcept {
359  const_iterator x=lower_bound(key);
360  if (x == end() || comp(key, *x)) return end();
361  return x;
362  }
363 
370  std::pair<iterator, iterator> equal_range(const Key & key) noexcept {
371  return std::equal_range(inner.begin(), inner.end(), key, comp);
372  }
373 
380  std::pair<const_iterator, const_iterator> equal_range(const Key & key) const noexcept {
381  return std::equal_range(inner.begin(), inner.end(), key, comp);
382  }
383 
388  iterator lower_bound(const Key & key) noexcept {
389  return std::lower_bound(inner.begin(), inner.end(), key, comp);
390  }
391 
396  const_iterator lower_bound(const Key & key) const noexcept {
397  return std::lower_bound(inner.begin(), inner.end(), key, comp);
398  }
399 
404  iterator upper_bound(const Key & key) noexcept {
405  return std::upper_bound(inner.begin(), inner.end(), key, comp);
406  }
407 
412  const_iterator upper_bound(const Key & key) const noexcept {
413  return std::upper_bound(inner.begin(), inner.end(), key, comp);
414  }
415 
420  template <typename K>
421  iterator lower_bound(const K & key) noexcept {
422  return std::lower_bound(inner.begin(), inner.end(), key, comp);
423  }
424 
429  template <typename K>
430  const_iterator lower_bound(const K & key) const noexcept {
431  return std::lower_bound(inner.begin(), inner.end(), key, comp);
432  }
433 
438  template <typename K>
439  iterator upper_bound(const K & key) noexcept {
440  return std::upper_bound(inner.begin(), inner.end(), key, comp);
441  }
442 
447  template <typename K>
448  const_iterator upper_bound(const K & key) const noexcept {
449  return std::upper_bound(inner.begin(), inner.end(), key, comp);
450  }
451 
452 
457  key_compare key_comp() const noexcept {
458  return comp.comp;
459  }
460 
466  value_compare value_comp() const noexcept {
467  return comp;
468  }
469 
473  allocator_type get_allocator() const {
474  return inner.get_allocator();
475  }
476 
480  set_impl & operator=(const set_impl& other ) {
481  inner = other.inner;
482  comp = other.comp;
483  return *this;
484  }
485 
492  inner = std::move(other.inner);
493  comp = std::move(other.comp);
494  return *this;
495  }
496 
500  set_impl& operator=(std::initializer_list<value_type> ilist) {
501  clear();
502  insert(ilist);
503  return *this;
504  }
505 
509  friend bool operator==(const set_impl & lhs, const set_impl & rhs) {
510  return lhs.inner == rhs.inner;
511  }
512 
516  friend bool operator!=(const set_impl & lhs, const set_impl & rhs) {
517  return lhs.inner != rhs.inner;
518  }
519 
524  friend bool operator<(const set_impl & lhs, const set_impl & rhs) {
525  return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), lhs.comp);
526  }
527 
532  friend bool operator<=(const set_impl & lhs, const set_impl & rhs) {
533  return !std::lexicographical_compare(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());
534 
535  }
536 
541  friend bool operator>(const set_impl & lhs, const set_impl & rhs) {
542  return std::lexicographical_compare(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());
543  }
544 
549  friend bool operator>=(const set_impl & lhs, const set_impl & rhs) {
550  return !std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), lhs.comp);
551  }
552 
557  friend void swap(set_impl & lhs, set_impl & rhs) {lhs.swap(rhs);}
558 
559 
563  size_t count(const Key k) const noexcept {
564  if (IH::multi) {
565  auto x=equal_range(k);
566  return x.second - x.first;
567  } else {
568  auto x=lower_bound(k);
569  if (x == end() || comp(k, *x)) return 0;
570  return 1;
571  }
572  }
573 
583  insert_result insert(const T & t) {
584  inner.push_back(t);
585  return IH::handle(inner, comp);
586  }
587 
597  template <typename TT>
598  insert_result insert(TT && t) {
599  return emplace(std::forward<TT>(t));
600  }
601 
605  insert_result insert(const_iterator /*hint*/, const T & t) {
606  return insert(t);
607  }
608 
612  template <typename TT>
613  insert_result insert(const_iterator /*hint*/, TT && t) {
614  return insert(std::forward<TT>(t));
615  }
616 
620  template <class InputIt>
621  void insert(InputIt first, InputIt last) {
622  inner.reserve(size() + last-first);
623  for (InputIt i=first; i != last; ++i)
624  insert(*i);
625  }
626 
630  void insert(std::initializer_list<value_type> list) {
631  insert(list.begin(), list.end());
632  }
633 
644  template <class... Args>
645  insert_result emplace(Args &&... args) {
646  inner.emplace_back(std::forward<Args>(args)...);
647  return IH::handle(inner, comp);
648  }
649 
653  template <class... Args>
654  insert_result emplace_hint(const_iterator /*hint*/, Args &&... args) {
655  return emplace(std::forward<Args>(args)...);
656  }
657 
664  void reserve(size_t new_cap) {inner.reserve(new_cap);}
665 
669  void shrink_to_fit() {inner.shrink_to_fit();}
670 
675  size_t capacity() const noexcept {return inner.capacity();}
676 protected:
677  value_compare comp;
678  std::vector<value_type, Alloc> inner;
679 };
680 
684 template <typename T,
685  typename Comp=std::less<T>,
686  typename Alloc=std::allocator<T> >
687 using set = set_impl<T, T, bits::IdentityExtract, Comp, Alloc, bits::SingleInsertHelp>;
688 
692 template <typename T,
693  typename Comp=std::less<T>,
694  typename Alloc=std::allocator<T> >
695 using multiset = set_impl<T, T, bits::IdentityExtract, Comp, Alloc, bits::MultiInsertHelp>;
696 
700 template <typename Key,
701  typename T,
702  typename Comp=std::less<Key>,
703  typename Alloc=std::allocator<std::pair<Key, T> > >
704 using multimap = set_impl<std::pair<Key, T>, T, bits::PairExtract<Key, T>, Comp, Alloc, bits::MultiInsertHelp>;
705 
709 template <typename Key,
710  typename T,
711  typename Comp=std::less<Key>,
712  typename Alloc=std::allocator<std::pair<Key, T> >
713  > class map: public set_impl<std::pair<Key, T>, T, bits::PairExtract<Key, T>, Comp, Alloc, bits::SingleInsertHelp> {
714 private:
716 public:
717 
718  map() {}
719  explicit map(const Comp & comp, const Alloc & alloc = Alloc()) : P(comp, alloc) {}
720  explicit map(const Alloc & alloc) : P(alloc) {}
721  map(const map & other) : P(other) {}
722  map(const map & other, const Alloc & alloc) : P(other, alloc) {}
723  map(map && other) : P(other) {}
724  map(map && other, const Alloc & alloc) : P(std::move(other), alloc) {}
725  template< class InputIterator >
726  map(InputIterator first, InputIterator last,
727  const Comp& comp = Comp(),
728  const Alloc& alloc = Alloc()) : P(first, last, comp, alloc) {}
729  map(std::initializer_list<typename P::value_type> init,
730  const Comp& comp = Comp(),
731  const Alloc& alloc = Alloc()) : P(init, comp, alloc) {}
732 
733  //using P::P; we must explicity copy the constructors until VS supports this
734 
740  T & operator[](const Key & key) {
741  return this->emplace(key, T()).first->second;
742  }
743 
749  T & operator[](Key && key) {
750  return this->emplace(std::move(key), T()).first->second;
751  }
752 
758  T& at( const Key& key ) {
759  typename P::iterator x=P::lower_bound(key);
760  if (x == P::end() || P::comp(key, *x)) throw std::out_of_range("tiny::map::at");
761  return x->second;
762  }
763 
769  const T& at( const Key& key ) const {
770  typename P::const_iterator x=P::lower_bound(key);
771  if (x == P::end() || P::comp(key, *x)) throw std::out_of_range("tiny::map::at");
772  return x->second;
773  }
774 };
775 
776 } //namespace tiny
777 } //namespace tpie;
778 
779 #endif //__TPIE_TINY_H__
tpie::tiny::set_impl::insert
insert_result insert(const_iterator, TT &&t)
Does the same as normal insert, we ignore the hint.
Definition: tiny.h:613
tpie::tiny::set_impl::reserve
void reserve(size_t new_cap)
Increase the capacity of the container to a value that's greater or equal to new_cap.
Definition: tiny.h:664
tpie::tiny::map::operator[]
T & operator[](Key &&key)
Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion i...
Definition: tiny.h:749
tpie::tiny::set_impl::operator>
friend bool operator>(const set_impl &lhs, const set_impl &rhs)
true if the contents of the lhs are lexicographically greater than the contents of rhs,...
Definition: tiny.h:541
tpie::tiny::set_impl::set_impl
set_impl(InputIterator first, InputIterator last, const Comp &comp=Comp(), const Alloc &alloc=Alloc())
Constructs the container with the contents of the range [first, last).
Definition: tiny.h:201
tpie::tiny::bits::PairExtract
Extract the first element of a pair as the key.
Definition: tiny.h:67
tpie::tiny::set_impl::swap
void swap(set_impl &o)
Exchanges the contents of the container with those of other.
Definition: tiny.h:339
tpie::tiny::set_impl::insert
insert_result insert(const_iterator, const T &t)
Does the same as normal insert, we ignore the hint.
Definition: tiny.h:605
tpie::sort
void sort(uncompressed_stream< T > &instream, uncompressed_stream< T > &outstream, Compare comp, progress_indicator_base &indicator)
Sort elements of a stream using the given STL-style comparator object.
Definition: sort.h:141
tpie::tiny::bits::SingleInsertHelp::type
Definition: tiny.h:79
tpie::tiny::set_impl::size
size_t size() const noexcept
Returns the number of elements in the container, i.e.
Definition: tiny.h:288
tpie::tiny::set_impl::end
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:249
tpie::tiny::set_impl::begin
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: tiny.h:224
tpie::tiny::set_impl::empty
bool empty() const noexcept
Checks if the container has no elements, i.e.
Definition: tiny.h:283
tpie::tiny::set_impl::rend
reverse_iterator rend() noexcept
Returns a reverse iterator to the element following the last element of the reversed container.
Definition: tiny.h:265
tpie::tiny::set_impl::find
iterator find(const Key &key) noexcept
Finds an element with key equivalent to key.
Definition: tiny.h:348
tpie::tiny::set_impl::operator<=
friend bool operator<=(const set_impl &lhs, const set_impl &rhs)
true if the contents of the lhs are lexicographically less than or equal the contents of rhs,...
Definition: tiny.h:532
tpie::tiny::set_impl::operator>=
friend bool operator>=(const set_impl &lhs, const set_impl &rhs)
true if the contents of the lhs are lexicographically greater than or equal the contents of rhs,...
Definition: tiny.h:549
tpie::tiny::set_impl::upper_bound
const_iterator upper_bound(const Key &key) const noexcept
Returns an iterator pointing to the first element that is greater than key.
Definition: tiny.h:412
tpie::tiny::set_impl::emplace
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:645
tpie::tiny::set_impl::lower_bound
const_iterator lower_bound(const Key &key) const noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:396
tpie::tiny::set_impl::insert
void insert(std::initializer_list< value_type > list)
Inserts elements from initializer list ilist.
Definition: tiny.h:630
tpie::tiny::set_impl::shrink_to_fit
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: tiny.h:669
tpie::tiny::set_impl::begin
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: tiny.h:219
tpie::tiny::set_impl::set_impl
set_impl(set_impl &&other)
Move constructor.
Definition: tiny.h:190
tpie::tiny::set_impl::rbegin
reverse_iterator rbegin() noexcept
Returns a reverse iterator to the first element of the reversed container.
Definition: tiny.h:234
tpie::tiny::set_impl::erase
iterator erase(iterator first, iterator last)
Removes the elements in the range [first; last), which must be a valid range in *this.
Definition: tiny.h:317
tpie::tiny::bits::IdentityExtract
Use the identity function on elements to extract the key.
Definition: tiny.h:57
tpie::tiny::set_impl::count
size_t count(const Key k) const noexcept
Returns the number of elements with key k.
Definition: tiny.h:563
tpie::tiny::set_impl::rbegin
const_reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the first element of the reversed container.
Definition: tiny.h:239
tpie::tiny::set_impl::lower_bound
iterator lower_bound(const K &key) noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:421
tpie::tiny::set_impl::value_comp
value_compare value_comp() const noexcept
Returns a function object that compares objects of type std::map::value_type (key-value pairs) by usi...
Definition: tiny.h:466
tpie::tiny::bits::MultiInsertHelp::type
Definition: tiny.h:103
tpie::tiny::set_impl::capacity
size_t capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition: tiny.h:675
tpie::tiny::map::at
const T & at(const Key &key) const
Returns a reference to the mapped value of the element with key equivalent to key.
Definition: tiny.h:769
tpie::tiny::set_impl::equal_range
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const noexcept
Returns a range containing all elements with the given key in the container.
Definition: tiny.h:380
tpie::tiny::set_impl::insert
insert_result insert(const T &t)
Inserts element(s) into the container, if the container doesn't already contain an element with an eq...
Definition: tiny.h:583
tpie::tiny::map::at
T & at(const Key &key)
Returns a reference to the mapped value of the element with key equivalent to key.
Definition: tiny.h:758
tpie::tiny::set_impl::operator=
set_impl & operator=(std::initializer_list< value_type > ilist)
Replaces the contents with those identified by initializer list ilist.
Definition: tiny.h:500
tpie::tiny::set_impl::end
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:254
tpie::tiny::set_impl::cend
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: tiny.h:259
tpie::tiny::set_impl::lower_bound
const_iterator lower_bound(const K &key) const noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:430
tpie::tiny::set_impl::crbegin
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the first element of the reversed container.
Definition: tiny.h:244
tpie::tiny::set_impl::upper_bound
iterator upper_bound(const K &key) noexcept
Returns an iterator pointing to the first element that is greater than key.
Definition: tiny.h:439
tpie::tiny::set_impl::value_compare
Definition: tiny.h:152
tpie::tiny::set_impl::upper_bound
iterator upper_bound(const Key &key) noexcept
Returns an iterator pointing to the first element that is greater than key.
Definition: tiny.h:404
tpie::tiny::set_impl::max_size
size_t max_size() const noexcept
Returns the maximum number of elements the container is able to hold due to system or library impleme...
Definition: tiny.h:295
tpie::tiny::set_impl::erase
size_t erase(const Key &key)
Removes all elements with the key value key.
Definition: tiny.h:327
tpie::tiny::set_impl::set_impl
set_impl(const set_impl &other, const Alloc &alloc)
Copy constructor.
Definition: tiny.h:185
tpie::tiny::set_impl::operator==
friend bool operator==(const set_impl &lhs, const set_impl &rhs)
true if the contents of the containers are equal, false otherwise.
Definition: tiny.h:509
tpie::tiny::set_impl::equal_range
std::pair< iterator, iterator > equal_range(const Key &key) noexcept
Returns a range containing all elements with the given key in the container.
Definition: tiny.h:370
tpie::tiny::set_impl::set_impl
set_impl(set_impl &&other, const Alloc &alloc)
Move constructor.
Definition: tiny.h:195
tpie::tiny::set_impl::set_impl
set_impl()
Default constructor.
Definition: tiny.h:165
tpie::tiny::set_impl
class implementing a tiny::set, tiny::multiset, and tiny::multimap.
Definition: tiny.h:137
tpie::tiny::set_impl::clear
void clear()
Removes all elements from the container.
Definition: tiny.h:300
tpie::tiny::set_impl::crend
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the element following the last element of the reversed container.
Definition: tiny.h:277
tpie::tiny::set_impl::erase
iterator erase(iterator pos)
Removes the element at pos.
Definition: tiny.h:306
tpie::tiny::set_impl::insert
insert_result insert(TT &&t)
Inserts element(s) into the container, if the container doesn't already contain an element with an eq...
Definition: tiny.h:598
tpie::tiny::set_impl::cbegin
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: tiny.h:229
tpie::tiny::set_impl::operator<
friend bool operator<(const set_impl &lhs, const set_impl &rhs)
true if the contents of the lhs are lexicographically less than the contents of rhs,...
Definition: tiny.h:524
tpie::tiny::set_impl::operator=
set_impl & operator=(const set_impl &other)
Copy assignment operator.
Definition: tiny.h:480
tpie::tiny::bits::MultiInsertHelp
When inserting allow elements with equivalest keys.
Definition: tiny.h:101
tpie::tiny::set_impl::set_impl
set_impl(const Alloc &alloc)
Default constructor.
Definition: tiny.h:175
tpie::tiny::map::operator[]
T & operator[](const Key &key)
Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion i...
Definition: tiny.h:740
tpie::tiny::set_impl::lower_bound
iterator lower_bound(const Key &key) noexcept
Returns an iterator pointing to the first element that is not less than key.
Definition: tiny.h:388
tpie::tiny::set_impl::operator=
set_impl & operator=(set_impl &&other)
Move assignment operator.
Definition: tiny.h:491
tpie::tiny::set_impl::set_impl
set_impl(const Comp &comp, const Alloc &alloc=Alloc())
Default constructor.
Definition: tiny.h:170
tpie::tiny::set_impl::key_comp
key_compare key_comp() const noexcept
Returns the function object that compares the keys, which is a copy of this container's constructor a...
Definition: tiny.h:457
tpie::tiny::set_impl::get_allocator
allocator_type get_allocator() const
Returns the allocator associated with the container.
Definition: tiny.h:473
tpie::tiny::set_impl::set_impl
set_impl(std::initializer_list< value_type > init, const Comp &comp=Comp(), const Alloc &alloc=Alloc())
Constructs the container with the contents of the initializer list init.
Definition: tiny.h:210
tpie::tiny::set_impl::swap
friend void swap(set_impl &lhs, set_impl &rhs)
Specializes the std::swap algorithm using adl.
Definition: tiny.h:557
tpie::tiny::set_impl::operator!=
friend bool operator!=(const set_impl &lhs, const set_impl &rhs)
true if the contents of the containers are not equal, false otherwise.
Definition: tiny.h:516
tpie::tiny::set_impl::rend
const_reverse_iterator rend() const noexcept
Returns a reverse iterator to the element following the last element of the reversed container.
Definition: tiny.h:271
tpie::tiny::set_impl::find
const_iterator find(const Key &key) const noexcept
Finds an element with key equivalent to key.
Definition: tiny.h:358
tpie::tiny::set_impl::set_impl
set_impl(const set_impl &other)
Copy constructor.
Definition: tiny.h:180
tpie
Definition: access_type.h:26
tpie::tiny::set_impl::insert
void insert(InputIt first, InputIt last)
Inserts elements from range [first, last).
Definition: tiny.h:621
tpie::tiny::set_impl::emplace_hint
insert_result emplace_hint(const_iterator, Args &&... args)
Do the same as emplace, and ignore the hint.
Definition: tiny.h:654
tpie::tiny::set_impl::upper_bound
const_iterator upper_bound(const K &key) const noexcept
Returns an iterator pointing to the first element that is greater than key.
Definition: tiny.h:448
tpie::tiny::map
A std::map compatible map, useful when we do not have many elements (less then 512)
Definition: tiny.h:713
tpie::tiny::bits::SingleInsertHelp
When inserting do not allow elements with equivalest keys.
Definition: tiny.h:77