CGRA-ME
Collections.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * The software programs comprising "CGRA-ME" and the documentation provided
3  * with them are copyright by its authors and the University of Toronto. Only
4  * non-commercial, not-for-profit use of this software is permitted without ex-
5  * plicit permission. This software is provided "as is" with no warranties or
6  * guarantees of support. See the LICENCE for more details. You should have re-
7  * ceived a copy of the full licence along with this software. If not, see
8  * <http://cgra-me.ece.utoronto.ca/license/>.
9  ******************************************************************************/
10 
11 #ifndef __UTILITY_COLLECTIONS_H__
12 #define __UTILITY_COLLECTIONS_H__
13 
14 #include <algorithm>
15 #include <numeric>
16 #include <utility>
17 #include <vector>
18 
22 template<typename BIter, typename EIter = BIter>
24  BIter b;
25  EIter e;
26 
27  template<typename BIter_C, typename EIter_C = BIter_C>
28  iterator_range(BIter_C&& b_, EIter_C&& e_)
29  : b(std::forward<BIter_C>(b_))
30  , e(std::forward<EIter_C>(e_))
31  { }
32 
33  iterator_range(const iterator_range&) = default;
34  iterator_range& operator=(const iterator_range&) = default;
35  iterator_range(iterator_range&&) = default;
37 
38  const BIter& begin() const { return b; }
39  BIter& begin() { return b; }
40 
41  const EIter& end() const { return e; }
42  EIter& end() { return e; }
43 
44  bool empty() const { return begin() != end(); }
45 };
46 
47 template<typename BIter, typename EIter = BIter>
48 auto make_iterator_range(BIter&& b, EIter&& e) {
49  using irange_type = iterator_range< std::decay_t<BIter>, std::decay_t<EIter> >;
50  return irange_type(std::forward<BIter>(b), std::forward<EIter>(e));
51 }
52 
53 template<typename BIter, typename EIter = BIter>
54 auto make_iterator_range(const std::pair<BIter, EIter>& p) {
55  using irange_type = iterator_range< std::decay_t<BIter>, std::decay_t<EIter> >;
56  return irange_type(p.first, p.second);
57 }
58 
59 template<typename Range, typename = decltype(begin(std::declval<Range>()))>
60 auto make_iterator_range(const Range& r) {
61  using std::begin;
62  using std::end;
63  return make_iterator_range(begin(r), end(r));
64 }
65 
71 template<int get_index, typename Range>
73  Range r;
74  using Biter = std::remove_cv_t<std::remove_reference_t<decltype(r.begin())>>;
75  using Eiter = std::remove_cv_t<std::remove_reference_t<decltype(r.end())>>;
76 
77  template<typename Iter>
78  struct iterator {
79  Iter impl;
80  iterator& operator++() { ++impl; return *this; }
81  auto& operator*() { using std::get; return get<get_index>(*impl); }
82  auto& operator*() const { using std::get; return get<get_index>(*impl); }
83  auto* operator->() { return &this->operator*(); }
84  auto* operator->() const { return &this->operator*(); }
85 
86  template<typename RHSIter>
87  bool operator==(const iterator<RHSIter>& rhs) {return this->impl == rhs.impl; }
88  template<typename RHSIter>
89  bool operator!=(const iterator<RHSIter>& rhs) {return this->impl != rhs.impl; }
90  template<typename RHSIter>
91  bool operator< (const iterator<RHSIter>& rhs) {return this->impl < rhs.impl; }
92  };
93 
94  iterator<Biter> begin() { return {r.begin()}; }
95  iterator<Eiter> end() { return {r.end()}; }
96  iterator<Biter> begin() const { return {((const Range)r).begin()}; }
97  iterator<Eiter> end() const { return {((const Range)r).end()}; }
98 };
99 
100 template<int get_index, typename Range>
102  return {r};
103 }
104 
105 template<typename Range>
107  return {r};
108 }
109 
110 template<typename Range>
112  return {r};
113 }
114 
115 template<typename Range>
116 auto reversed(Range& r) {
117  return make_iterator_range(r.rbegin(), r.rend());
118 }
119 
124 template<typename VertexID>
126  const VertexID v;
127 
128  auto begin() const { return &v; }
129  auto end() const { return &v + 1; }
130 
131  template<typename Q> auto find(const Q& q) const { return (v == q) ? begin() : end(); }
132  template<typename Q> std::ptrdiff_t count(const Q& q) { return (v == q) ? 1 : 0; }
133 };
134 
135 template<typename VertexID> auto cbegin(const SingleItemImmutableSet<VertexID>& siis) { return siis.begin(); }
136 template<typename VertexID> auto cend(const SingleItemImmutableSet<VertexID>& siis) { return siis.end(); }
137 template<typename VertexID> auto begin(const SingleItemImmutableSet<VertexID>& siis) { return siis.begin(); }
138 template<typename VertexID> auto end(const SingleItemImmutableSet<VertexID>& siis) { return siis.end(); }
139 template<typename VertexID> auto begin( SingleItemImmutableSet<VertexID>& siis) { return siis.begin(); }
140 template<typename VertexID> auto end( SingleItemImmutableSet<VertexID>& siis) { return siis.end(); }
141 
142 template<typename VertexID>
144  return { std::move(v) };
145 }
146 
147 template<template <typename...> class Map, typename... InitialParams>
149  template<typename... RestParams>
150  auto operator()() const {
151  return Map<InitialParams..., RestParams...>();
152  }
153 };
154 
155 template<template <typename...> class Set, typename... InitialParams>
157  template<typename... RestParams>
158  auto operator()() const {
159  return Set<InitialParams..., RestParams...>();
160  }
161 };
162 
163 
167 template<typename IndexMap, typename Key, typename MappedType>
168 struct VectorMap {
169  using value_type = std::pair<Key, MappedType>;
170  using DataStore = std::vector<value_type>;
171 
172  struct const_iterator {
173  typename DataStore::const_iterator impl;
174  auto& operator*() const { return *impl; }
175  auto* operator->() const { return &*impl; }
176  bool operator==(const const_iterator& rhs) const { return impl == rhs.impl; }
177  bool operator!=(const const_iterator& rhs) const { return impl != rhs.impl; }
178  };
179  struct iterator {
180  typename DataStore::iterator impl;
181  auto& operator*() const { return *impl; }
182  auto* operator->() const { return &*impl; }
183  bool operator==(const iterator& rhs) const { return impl == rhs.impl; }
184  bool operator!=(const iterator& rhs) const { return impl != rhs.impl; }
185  operator const_iterator() const { return {impl}; }
186  };
187 
188  VectorMap(std::size_t size) : VectorMap(size, IndexMap()) {}
189  VectorMap(std::size_t size, IndexMap imap)
190  : imap(std::move(imap))
191  , data(size, {imap.invalid_key(), MappedType()}) {}
192 
193  const MappedType& at(const Key& k) const {
194  return iterAt(k)->second;
195  }
196  MappedType& at(const Key& k) {
197  return iterAt(k)->second;
198  }
199  MappedType& operator[](const Key& k) {
200  auto i = iterAt(k);
201  i->first = k;
202  return i->second;
203  }
204 
205  std::pair<iterator, bool> insert(value_type vt) {
206  auto i = iterAt(vt.first);
207  bool had_no_data = not has_data(i);
208  if (had_no_data) *i = vt;
209  return {i, had_no_data};
210  }
211 
212  iterator find(const Key& k) {
213  auto i = iterAt(k);
214  return has_data(i) ? i : end();
215  }
216  const_iterator find(const Key& k) const {
217  auto i = iterAt(k);
218  return has_data(i) ? i : end();
219  }
220 
221  std::size_t count(const Key& k) const { return find(k) == end() ? 0 : 1; }
222 
223  iterator end() { return {data.end()}; }
224  const_iterator end() const { return {data.end()}; }
225 
226  private:
227  iterator iterAt(const Key& k) { return {data.begin() + imap(k)}; }
228  const_iterator iterAt(const Key& k) const { return {data.begin() + imap(k)}; }
229  bool has_data(const_iterator i) const { return i->first != imap.invalid_key(); }
230 
232  IndexMap imap;
233 };
234 
238 template<typename IndexMap, typename Value>
239 struct VectorSet {
240  using value_type = Value;
241  using DataStore = std::vector<value_type>;
242 
243  struct const_iterator {
244  typename DataStore::const_iterator impl;
245  auto& operator*() const { return *impl; }
246  auto* operator->() const { return &*impl; }
247  bool operator==(const const_iterator& rhs) const { return impl == rhs.impl; }
248  bool operator!=(const const_iterator& rhs) const { return impl != rhs.impl; }
249  };
250  struct iterator {
251  typename DataStore::iterator impl;
252  auto& operator*() const { return *impl; }
253  auto* operator->() const { return &*impl; }
254  bool operator==(const iterator& rhs) const { return impl == rhs.impl; }
255  bool operator!=(const iterator& rhs) const { return impl != rhs.impl; }
256  operator const_iterator() const { return {impl}; }
257  };
258 
259  VectorSet(std::size_t size) : VectorSet(size, IndexMap()) {}
260  VectorSet(std::size_t size, IndexMap imap)
261  : imap(std::move(imap))
262  , data(size, imap.invalid_key()) {}
263 
264  std::pair<iterator, bool> insert(value_type vt) {
265  auto i = iterAt(vt);
266  bool had_no_data = not has_data(i);
267  if (had_no_data) *i = vt;
268  return {i, had_no_data};
269  }
270 
272  auto i = iterAt(k);
273  return has_data(i) ? i : end();
274  }
275  const_iterator find(const value_type& k) const {
276  auto i = iterAt(k);
277  return has_data(i) ? i : end();
278  }
279 
280  std::size_t count(const value_type& k) const { return find(k) == end() ? 0 : 1; }
281 
282  iterator end() { return {data.end()}; }
283  const_iterator end() const { return {data.end()}; }
284 
285  private:
286  iterator iterAt(const value_type& k) { return {data.begin() + imap(k)}; }
287  const_iterator iterAt(const value_type& k) const { return {data.begin() + imap(k)}; }
288  bool has_data(iterator i) const { return *i != imap.invalid_key(); }
289 
290  IndexMap imap;
292 };
293 
294 template<typename... InitialParams>
296  std::size_t size;
297  template<typename... RestParams>
298  auto operator()() const {
299  return VectorMap<InitialParams..., RestParams...>(size);
300  }
301 };
302 
303 template<typename... InitialParams>
305  std::size_t size;
306  template<typename...>
307  auto operator()() const {
308  return VectorSet<InitialParams...>(size);
309  }
310 };
311 
316 template<typename COLLECTION, typename UNARY_PREDICATE>
317 auto filter_collection(const COLLECTION& base_container, UNARY_PREDICATE&& filter) {
318  COLLECTION result;
319  std::copy_if(begin(base_container), end(base_container), std::inserter(result, end(result)), filter);
320  return result;
321 }
322 
327 template<typename R1, typename R2>
328 bool are_ranges_same(const R1& r1, const R2& r2) {
329  return std::mismatch(begin(r1), end(r1), begin(r2), end(r2)) == std::make_pair(end(r1), end(r2));
330 }
331 
338 template<typename ASSOCIATIVE_COLLECTION, typename KEY, typename DEFAULT_VALUE>
339 auto value_for_key_or(ASSOCIATIVE_COLLECTION& assoc_collection, const KEY& key, DEFAULT_VALUE& default_value)
340  -> std::conditional_t<
341  std::is_lvalue_reference<DEFAULT_VALUE>::value,
342  decltype(false ? default_value : assoc_collection.find(key)->second)&,
343  decltype(false ? default_value : assoc_collection.find(key)->second)
344  >
345 {
346  const auto search_result = assoc_collection.find(key);
347  if (search_result == end(assoc_collection)) {
348  return default_value;
349  } else {
350  return search_result->second;
351  }
352 }
353 
357 template<typename ASSOCIATIVE_COLLECTION, typename KEY, typename VALUE>
358 auto insert_or_assign(ASSOCIATIVE_COLLECTION& assoc_collection, KEY&& key, VALUE&& value) {
359  const auto search_result = assoc_collection.find(key);
360  if (search_result == end(assoc_collection)) {
361  return assoc_collection.emplace(std::forward<KEY>(key), std::forward<VALUE>(value));
362  } else {
363  search_result->second = std::forward<KEY>(value);
364  return std::make_pair(search_result, true);
365  }
366 }
367 
372 template<typename InputIt, typename ForwardIt, typename BinaryPredicate>
373 std::pair<InputIt,ForwardIt> find_first_of_and_matching(
374  InputIt first, InputIt last,
375  ForwardIt s_first, ForwardIt s_last,
376  BinaryPredicate p
377 ) {
378  for (; first != last; ++first) {
379  for (ForwardIt it = s_first; it != s_last; ++it) {
380  if (p(*first, *it)) {
381  return {first,it};
382  }
383  }
384  }
385  return {last, s_last};
386 }
387 
388 // version of abvove without a predicate, uses operator==
389 template<typename InputIt, typename ForwardIt>
391  InputIt first, InputIt last,
392  ForwardIt s_first, ForwardIt s_last
393 ) {
395  first, last, s_first, s_last,
396  [](auto&& lhs, auto&& rhs) { return lhs == rhs; }
397  );
398 }
399 
400 // range version of above
401 template<typename Range1, typename Range2, typename BinaryPredicate>
402 auto find_first_of_and_matching(Range1&& r1, Range2& r2, BinaryPredicate p) {
403  using std::begin; using std::end;
404  return find_first_of_and_matching(begin(r1), end(r1), begin(r2), end(r2), std::move(p));
405 }
406 
407 // range version of above, uses operator==
408 template<typename Range1, typename Range2>
409 auto find_first_of_and_matching(Range1&& r1, Range2& r2) {
410  using std::begin; using std::end;
411  return find_first_of_and_matching(begin(r1), end(r1), begin(r2), end(r2));
412 }
413 
414 namespace detail {
416  template<typename STREAM, typename T>
417  void operator()(STREAM& os, const T& t) const {
418  os << t;
419  }
420  };
421 }
422 
429 template<
430  typename CONTAINER,
431  typename OSTREAM,
432  typename PRINTER = detail::shift_in_printer,
433  typename T1, typename T2, typename T3
434 >
436  OSTREAM&& os,
437  const CONTAINER& c,
438  const T1& element_separator,
439  const T2& container_prefix,
440  const T3& container_suffix,
441  PRINTER&& element_printer = PRINTER{}
442 ) {
443  using std::begin; using std::end;
444  auto beg = begin(c);
445  auto en = end(c);
446 
447  os << container_prefix;
448  if (beg != en) {
449  element_printer(os,*beg);
450  std::for_each(std::next(beg), en, [&](const auto& v){
451  os << element_separator;
452  element_printer(os,v);
453  });
454  }
455  os << container_suffix;
456 }
457 
466 template<typename CONTAINER, typename OSTREAM, typename PRINTER = detail::shift_in_printer>
468  OSTREAM&& os,
469  const CONTAINER& c,
470  PRINTER&& element_printer = PRINTER{}
471 ) {
472  print_container(os, c, ", ", "{ ", " }", element_printer);
473 }
474 
481 template<
482  typename ASSOC_CONTAINER,
483  typename OSTREAM,
484  typename KEY_PRINTER = detail::shift_in_printer,
485  typename VALUE_PRINTER = detail::shift_in_printer,
486  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6
487 >
489  OSTREAM&& os,
490  const ASSOC_CONTAINER& c,
491  const T1& element_separator,
492  const T2& key_value_separator,
493  const T3& element_prefix,
494  const T4& element_suffix,
495  const T5& container_prefix,
496  const T6& container_suffix,
497  KEY_PRINTER&& value_printer = KEY_PRINTER{},
498  VALUE_PRINTER&& key_printer = VALUE_PRINTER{}
499 ) {
500  using std::begin; using std::end;
501  auto beg = begin(c);
502  auto en = end(c);
503 
504  os << container_prefix;
505  if (beg != en) {
506  os << element_prefix;
507  key_printer(os,beg->first);
508  os << key_value_separator;
509  value_printer(os,beg->second);
510  os << element_suffix;
511  std::for_each(std::next(beg), en, [&](const auto& v){
512  os << element_separator;
513  os << element_prefix;
514  key_printer(os,v.first);
515  os << key_value_separator;
516  value_printer(os,v.second);
517  os << element_suffix;
518  });
519  }
520  os << container_suffix;
521 }
522 
531 template<typename ASSOC_CONTAINER, typename OSTREAM, typename KEY_PRINTER = detail::shift_in_printer, typename VALUE_PRINTER = detail::shift_in_printer>
533  OSTREAM&& os,
534  const ASSOC_CONTAINER& c,
535  KEY_PRINTER&& value_printer = KEY_PRINTER{},
536  VALUE_PRINTER&& key_printer = VALUE_PRINTER{}
537 ) {
538  print_assoc_container(os, c, ", ", " -> ", "{ ", " }", "{", "}", value_printer, key_printer);
539 }
540 
541 template<typename T = std::vector<int>>
542 T make_zero_to_n_minus_one_list(std::ptrdiff_t n) {
543  T result(n);
544  std::iota(result.begin(), result.end(), 0);
545  return result;
546 }
547 
548 #endif /* __UTILITY_COLLECTIONS_H__ */
VectorMap::at
const MappedType & at(const Key &k) const
Definition: Collections.h:193
VectorMap::VectorMap
VectorMap(std::size_t size)
Definition: Collections.h:188
StandardMapMaker
Definition: Collections.h:148
tuple_get_range::r
Range r
Definition: Collections.h:73
VectorMap::operator[]
MappedType & operator[](const Key &k)
Definition: Collections.h:199
VectorMap::find
iterator find(const Key &k)
Definition: Collections.h:212
detail::shift_in_printer
Definition: Collections.h:415
VectorMap::find
const_iterator find(const Key &k) const
Definition: Collections.h:216
VectorMap::count
std::size_t count(const Key &k) const
Definition: Collections.h:221
iterator_range::e
EIter e
Definition: Collections.h:33
tuple_get_range::Biter
std::remove_cv_t< std::remove_reference_t< decltype(r.begin())> > Biter
Definition: Collections.h:74
VectorMap::iterator::operator*
auto & operator*() const
Definition: Collections.h:181
tuple_get_range::iterator::operator*
auto & operator*() const
Definition: Collections.h:82
VectorSet::VectorSet
VectorSet(std::size_t size, IndexMap imap)
Definition: Collections.h:260
VectorMap::const_iterator::operator!=
bool operator!=(const const_iterator &rhs) const
Definition: Collections.h:177
VectorMap::iterator::operator!=
bool operator!=(const iterator &rhs) const
Definition: Collections.h:184
VectorSet::value_type
Value value_type
Definition: Collections.h:240
VectorMap::DataStore
std::vector< value_type > DataStore
Definition: Collections.h:170
begin
auto begin(const SingleItemImmutableSet< VertexID > &siis)
Definition: Collections.h:137
VectorSet::iterator
Definition: Collections.h:250
VectorMap::iterator::impl
DataStore::iterator impl
Definition: Collections.h:180
tuple_get_range::iterator::operator*
auto & operator*()
Definition: Collections.h:81
tuple_get_range::iterator::operator==
bool operator==(const iterator< RHSIter > &rhs)
Definition: Collections.h:87
make_second_of_pair_range
tuple_get_range< 1, Range > make_second_of_pair_range(Range &&r)
Definition: Collections.h:106
VectorMap::const_iterator::operator==
bool operator==(const const_iterator &rhs) const
Definition: Collections.h:176
detail
Definition: Collections.h:414
VectorMap::end
iterator end()
Definition: Collections.h:223
VectorSet::insert
std::pair< iterator, bool > insert(value_type vt)
Definition: Collections.h:264
VectorMap::iterAt
iterator iterAt(const Key &k)
Definition: Collections.h:227
tuple_get_range::begin
iterator< Biter > begin() const
Definition: Collections.h:96
make_first_of_pair_range
tuple_get_range< 0, Range > make_first_of_pair_range(Range &&r)
Definition: Collections.h:111
find_first_of_and_matching
std::pair< InputIt, ForwardIt > find_first_of_and_matching(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinaryPredicate p)
Definition: Collections.h:373
iterator_range::iterator_range
iterator_range(BIter_C &&b_, EIter_C &&e_)
Definition: Collections.h:36
VectorSet::iterAt
iterator iterAt(const value_type &k)
Definition: Collections.h:286
tuple_get_range::end
iterator< Eiter > end() const
Definition: Collections.h:97
tuple_get_range::end
iterator< Eiter > end()
Definition: Collections.h:95
VectorMap::data
DataStore data
Definition: Collections.h:231
tuple_get_range::Eiter
std::remove_cv_t< std::remove_reference_t< decltype(r.end())> > Eiter
Definition: Collections.h:75
VectorSetMaker::size
std::size_t size
Definition: Collections.h:305
VectorSet::imap
IndexMap imap
Definition: Collections.h:290
make_iterator_range
auto make_iterator_range(BIter &&b, EIter &&e)
Definition: Collections.h:48
print_assoc_container
void print_assoc_container(OSTREAM &&os, const ASSOC_CONTAINER &c, const T1 &element_separator, const T2 &key_value_separator, const T3 &element_prefix, const T4 &element_suffix, const T5 &container_prefix, const T6 &container_suffix, KEY_PRINTER &&value_printer=KEY_PRINTER{}, VALUE_PRINTER &&key_printer=VALUE_PRINTER{})
Definition: Collections.h:488
tuple_get_range::iterator::operator->
auto * operator->() const
Definition: Collections.h:84
SingleItemImmutableSet::find
auto find(const Q &q) const
Definition: Collections.h:131
VectorMap::at
MappedType & at(const Key &k)
Definition: Collections.h:196
are_ranges_same
bool are_ranges_same(const R1 &r1, const R2 &r2)
Definition: Collections.h:328
StandardMapMaker::operator()
auto operator()() const
Definition: Collections.h:150
VectorMapMaker::operator()
auto operator()() const
Definition: Collections.h:298
VectorSet
Provides some standard set operations, with a fixed size.
Definition: Collections.h:239
iterator_range::end
const EIter & end() const
Definition: Collections.h:49
tuple_get_range::iterator::operator<
bool operator<(const iterator< RHSIter > &rhs)
Definition: Collections.h:91
make_tuple_get_range
tuple_get_range< get_index, Range > make_tuple_get_range(Range &&r)
Definition: Collections.h:101
tuple_get_range::iterator::impl
Iter impl
Definition: Collections.h:79
VectorSet::iterator::operator==
bool operator==(const iterator &rhs) const
Definition: Collections.h:254
VectorSet::const_iterator::impl
DataStore::const_iterator impl
Definition: Collections.h:244
SingleItemImmutableSet::count
std::ptrdiff_t count(const Q &q)
Definition: Collections.h:132
VectorMap::iterator::operator->
auto * operator->() const
Definition: Collections.h:182
VectorMapMaker
Definition: Collections.h:295
VectorSet::iterator::operator!=
bool operator!=(const iterator &rhs) const
Definition: Collections.h:255
tuple_get_range::iterator
Definition: Collections.h:78
VectorMap::const_iterator::operator->
auto * operator->() const
Definition: Collections.h:175
VectorMap::has_data
bool has_data(const_iterator i) const
Definition: Collections.h:229
VectorSet::end
iterator end()
Definition: Collections.h:282
VectorSet::const_iterator::operator*
auto & operator*() const
Definition: Collections.h:245
VectorSet::iterator::impl
DataStore::iterator impl
Definition: Collections.h:251
SingleItemImmutableSet::v
const VertexID v
Definition: Collections.h:126
SingleItemImmutableSet::end
auto end() const
Definition: Collections.h:129
VectorMap::iterator
Definition: Collections.h:179
iterator_range::b
BIter b
Definition: Collections.h:32
SingleItemImmutableSet::begin
auto begin() const
Definition: Collections.h:128
VectorMap::iterAt
const_iterator iterAt(const Key &k) const
Definition: Collections.h:228
VectorMap::value_type
std::pair< Key, MappedType > value_type
Definition: Collections.h:169
VectorSet::find
const_iterator find(const value_type &k) const
Definition: Collections.h:275
VectorSetMaker::operator()
auto operator()() const
Definition: Collections.h:307
VectorSet::const_iterator::operator->
auto * operator->() const
Definition: Collections.h:246
cbegin
auto cbegin(const SingleItemImmutableSet< VertexID > &siis)
Definition: Collections.h:135
VectorMap::const_iterator::impl
DataStore::const_iterator impl
Definition: Collections.h:173
VectorMap::end
const_iterator end() const
Definition: Collections.h:224
iterator_range::begin
const BIter & begin() const
Definition: Collections.h:46
end
auto end(const SingleItemImmutableSet< VertexID > &siis)
Definition: Collections.h:138
VectorSet::VectorSet
VectorSet(std::size_t size)
Definition: Collections.h:259
print_container
void print_container(OSTREAM &&os, const CONTAINER &c, const T1 &element_separator, const T2 &container_prefix, const T3 &container_suffix, PRINTER &&element_printer=PRINTER{})
Definition: Collections.h:435
VectorSet::data
DataStore data
Definition: Collections.h:291
tuple_get_range::begin
iterator< Biter > begin()
Definition: Collections.h:94
VectorSet::has_data
bool has_data(iterator i) const
Definition: Collections.h:288
value_for_key_or
auto value_for_key_or(ASSOCIATIVE_COLLECTION &assoc_collection, const KEY &key, DEFAULT_VALUE &default_value) -> std::conditional_t< std::is_lvalue_reference< DEFAULT_VALUE >::value, decltype(false ? default_value :assoc_collection.find(key) ->second)&, decltype(false ? default_value :assoc_collection.find(key) ->second) >
Definition: Collections.h:339
VectorSet::DataStore
std::vector< value_type > DataStore
Definition: Collections.h:241
VectorSet::end
const_iterator end() const
Definition: Collections.h:283
tuple_get_range::iterator::operator->
auto * operator->()
Definition: Collections.h:83
VectorSet::const_iterator::operator==
bool operator==(const const_iterator &rhs) const
Definition: Collections.h:247
VectorSet::const_iterator
Definition: Collections.h:243
VectorSet::iterator::operator->
auto * operator->() const
Definition: Collections.h:253
VectorSet::find
iterator find(const value_type &k)
Definition: Collections.h:271
detail::shift_in_printer::operator()
void operator()(STREAM &os, const T &t) const
Definition: Collections.h:417
VectorMap::const_iterator::operator*
auto & operator*() const
Definition: Collections.h:174
tuple_get_range::iterator::operator++
iterator & operator++()
Definition: Collections.h:80
StandardSetMaker
Definition: Collections.h:156
singleItemSet
SingleItemImmutableSet< VertexID > singleItemSet(VertexID v)
Definition: Collections.h:143
reversed
auto reversed(Range &r)
Definition: Collections.h:116
VectorMapMaker::size
std::size_t size
Definition: Collections.h:296
StandardSetMaker::operator()
auto operator()() const
Definition: Collections.h:158
VectorMap
Provides some standard map operations, with a fixed size.
Definition: Collections.h:168
VectorSetMaker
Definition: Collections.h:304
VectorMap::const_iterator
Definition: Collections.h:172
VectorMap::VectorMap
VectorMap(std::size_t size, IndexMap imap)
Definition: Collections.h:189
tuple_get_range
Definition: Collections.h:72
filter
OpGraphTransformResult filter(const OpGraph &src, const std::set< OpGraph::OpDescriptor > &allowed_ops)
Definition: OpGraph.cpp:1212
VectorSet::iterator::operator*
auto & operator*() const
Definition: Collections.h:252
VectorSet::const_iterator::operator!=
bool operator!=(const const_iterator &rhs) const
Definition: Collections.h:248
iterator_range
Definition: Collections.h:23
filter_collection
auto filter_collection(const COLLECTION &base_container, UNARY_PREDICATE &&filter)
Definition: Collections.h:317
iterator_range::empty
bool empty() const
Definition: Collections.h:52
cend
auto cend(const SingleItemImmutableSet< VertexID > &siis)
Definition: Collections.h:136
iterator_range::operator=
iterator_range & operator=(const iterator_range &)=default
insert_or_assign
auto insert_or_assign(ASSOCIATIVE_COLLECTION &assoc_collection, KEY &&key, VALUE &&value)
Definition: Collections.h:358
VectorMap::imap
IndexMap imap
Definition: Collections.h:232
VectorSet::count
std::size_t count(const value_type &k) const
Definition: Collections.h:280
SingleItemImmutableSet
Definition: Collections.h:125
VectorMap::iterator::operator==
bool operator==(const iterator &rhs) const
Definition: Collections.h:183
VectorSet::iterAt
const_iterator iterAt(const value_type &k) const
Definition: Collections.h:287
tuple_get_range::iterator::operator!=
bool operator!=(const iterator< RHSIter > &rhs)
Definition: Collections.h:89
make_zero_to_n_minus_one_list
T make_zero_to_n_minus_one_list(std::ptrdiff_t n)
Definition: Collections.h:542
VectorMap::insert
std::pair< iterator, bool > insert(value_type vt)
Definition: Collections.h:205