CatapultServer  v0.5.0.1 (Elephant)
OrderedSet.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "BaseSet.h"
23 #include "PruningBoundary.h"
24 #include <set>
25 
26 namespace catapult { namespace deltaset {
27 
29  template<typename TSet, typename X = decltype((*reinterpret_cast<TSet*>(0)).lower_bound(typename TSet::value_type()))>
30  void PruneBaseSet(TSet& elements, const PruningBoundary<typename TSet::value_type>& pruningBoundary) {
31  auto iter = elements.lower_bound(pruningBoundary.value());
32  elements.erase(elements.cbegin(), iter);
33  }
34 
35  namespace detail {
36  template<typename T>
37  using OrderedSetType = std::set<
38  std::remove_const_t<typename T::ElementType>,
39  std::less<typename T::ElementType>>;
40 
42  template<typename TSetTraits>
44  template<typename TPruningBoundary>
45  static void Update(
46  typename TSetTraits::SetType& elements,
48  const TPruningBoundary& pruningBoundary) {
49  UpdateSet<typename TSetTraits::KeyTraits>(elements, deltas);
50 
51  if (pruningBoundary.isSet())
52  PruneBaseSet(elements, pruningBoundary);
53  }
54  };
55  }
56 
58  template<typename TElementTraits, typename TStorageTraits = SetStorageTraits<detail::OrderedSetType<TElementTraits>>>
59  class OrderedSet : public BaseSet<TElementTraits, TStorageTraits, detail::OrderedSetCommitPolicy<TStorageTraits>> {
60  private:
62 
63  public:
64  using BaseType::BaseType;
65  };
66 
68  template<typename TElementTraits, typename TStorageTraits = SetStorageTraits<detail::OrderedSetType<TElementTraits>>>
70 }}
catapult::deltaset::BaseSetDelta
Definition: BaseSet.h:30
catapult::deltaset::PruningBoundary::value
constexpr const T & value() const
Returns the pruning boundary value.
Definition: PruningBoundary.h:44
PruningBoundary.h
catapult::deltaset::OrderedSet
A base set with ordered keys.
Definition: OrderedSet.h:59
catapult::deltaset::DeltaElements
Slim wrapper around changed elements.
Definition: DeltaElements.h:27
BaseSet.h
catapult::deltaset::detail::OrderedSetCommitPolicy::Update
static void Update(typename TSetTraits::SetType &elements, const DeltaElements< typename TSetTraits::MemorySetType > &deltas, const TPruningBoundary &pruningBoundary)
Definition: OrderedSet.h:45
catapult::deltaset::detail::OrderedSetType
std::set< std::remove_const_t< typename T::ElementType >, std::less< typename T::ElementType > > OrderedSetType
Definition: OrderedSet.h:39
catapult::deltaset::BaseSet
Definition: BaseSet.h:52
catapult::deltaset::PruneBaseSet
void PruneBaseSet(ConditionalContainer< TKeyTraits, TStorageSet, TMemorySet > &container, const TPruningBoundary &pruningBoundary)
Definition: ConditionalContainer.h:215
catapult::deltaset::PruningBoundary
Represents an optional pruning boundary.
Definition: PruningBoundary.h:27
catapult::deltaset::detail::OrderedSetCommitPolicy
Policy for committing changes to an ordered set.
Definition: OrderedSet.h:43
catapult
Definition: AddressExtractionExtension.cpp:28