CatapultServer  v0.5.0.1 (Elephant)
BaseSetIterationView.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "BaseSet.h"
23 
24 namespace catapult { namespace deltaset {
25 
27  template<typename TSetTraits>
28  class BaseSetIterationView {
29  private:
30  using SetType = typename TSetTraits::MemorySetType;
31  using KeyType = typename TSetTraits::KeyType;
32 
33  public:
35  explicit BaseSetIterationView(const SetType& set) : m_set(set)
36  {}
37 
38  public:
40  auto findIterator(const KeyType& key) const {
41  return m_set.find(key);
42  }
43 
44  public:
46  auto begin() const {
47  return m_set.cbegin();
48  }
49 
51  auto end() const {
52  return m_set.cend();
53  }
54 
55  private:
56  const SetType& m_set;
57  };
58 
60  template<typename TSet>
61  bool IsSetIterable(const TSet&) {
62  return true;
63  }
64 
66  template<typename TSet>
67  const TSet& SelectIterableSet(const TSet& set) {
68  return set;
69  }
70 
72  template<typename TElementTraits, typename TSetTraits, typename TCommitPolicy>
74  return IsSetIterable(set.m_elements);
75  }
76 
79  template<typename TElementTraits, typename TSetTraits, typename TCommitPolicy>
82  }
83 }}
catapult::deltaset::BaseSetIterationView::findIterator
auto findIterator(const KeyType &key) const
Returns an iterator that points to the element with key if it is contained in this set,...
Definition: BaseSetIterationView.h:40
catapult::deltaset::BaseSet::m_elements
SetType m_elements
Definition: BaseSet.h:125
catapult::deltaset::BaseSetIterationView::begin
auto begin() const
Returns a const iterator to the first element of the underlying set.
Definition: BaseSetIterationView.h:46
catapult::deltaset::IsSetIterable
bool IsSetIterable(const TSet &)
Returns true if set is iterable.
Definition: BaseSetIterationView.h:61
catapult::deltaset::BaseSetIterationView::SetType
typename TSetTraits::MemorySetType SetType
Definition: BaseSetIterationView.h:30
catapult::deltaset::IsBaseSetIterable
bool IsBaseSetIterable(const BaseSet< TElementTraits, TSetTraits, TCommitPolicy > &set)
Returns true if set is iterable.
Definition: BaseSetIterationView.h:73
catapult::deltaset::SelectIterableSet
const TSet & SelectIterableSet(const TSet &set)
Selects the iterable set from set.
Definition: BaseSetIterationView.h:67
catapult::deltaset::BaseSetIterationView::m_set
const SetType & m_set
Definition: BaseSetIterationView.h:56
BaseSet.h
catapult::deltaset::BaseSetIterationView::BaseSetIterationView
BaseSetIterationView(const SetType &set)
Creates a view around set.
Definition: BaseSetIterationView.h:35
catapult::deltaset::BaseSet
Definition: BaseSet.h:52
catapult::deltaset::BaseSetIterationView
A view that provides iteration support to a base set.
Definition: BaseSet.h:33
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::deltaset::BaseSetIterationView::end
auto end() const
Returns a const iterator to the element following the last element of the underlying set.
Definition: BaseSetIterationView.h:51
catapult::deltaset::BaseSetIterationView::KeyType
typename TSetTraits::KeyType KeyType
Definition: BaseSetIterationView.h:31
catapult::deltaset::MakeIterableView
BaseSetDeltaIterationView< TSetTraits > MakeIterableView(const BaseSetDelta< TElementTraits, TSetTraits > &delta)
Definition: BaseSetDeltaIterationView.h:200