CatapultServer  v0.5.0.1 (Elephant)
IdentifierGroup.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include <unordered_set>
23 
24 namespace catapult { namespace utils {
25 
27  template<typename TIdentifier, typename TGroupingKey, typename TIdentifierHasher>
29  public:
31  using Identifiers = std::unordered_set<TIdentifier, TIdentifierHasher>;
32 
34  using GroupingKeyType = TGroupingKey;
35 
36  public:
38  explicit IdentifierGroup(const TGroupingKey& key) : m_key(key)
39  {}
40 
41  public:
43  const TGroupingKey& key() const {
44  return m_key;
45  }
46 
48  const Identifiers& identifiers() const {
49  return m_identifiers;
50  }
51 
52  public:
54  bool empty() const {
55  return m_identifiers.empty();
56  }
57 
59  size_t size() const {
60  return m_identifiers.size();
61  }
62 
63  public:
65  void add(const TIdentifier& identifier) {
66  m_identifiers.insert(identifier);
67  }
68 
70  void remove(const TIdentifier& identifier) {
71  m_identifiers.erase(identifier);
72  }
73 
74  private:
75  TGroupingKey m_key;
77  };
78 }}
catapult::utils::IdentifierGroup::IdentifierGroup
IdentifierGroup(const TGroupingKey &key)
Creates a group around a given key.
Definition: IdentifierGroup.h:38
catapult::utils::IdentifierGroup::Identifiers
std::unordered_set< TIdentifier, TIdentifierHasher > Identifiers
Unordered set of identifiers.
Definition: IdentifierGroup.h:31
catapult::utils::IdentifierGroup::key
const TGroupingKey & key() const
Gets the grouping key.
Definition: IdentifierGroup.h:43
catapult::utils::IdentifierGroup::empty
bool empty() const
Returns true if the group is empty, false otherwise.
Definition: IdentifierGroup.h:54
catapult::utils::IdentifierGroup::size
size_t size() const
Gets the number of identifiers in the group.
Definition: IdentifierGroup.h:59
catapult::utils::IdentifierGroup::identifiers
const Identifiers & identifiers() const
Gets the identifiers.
Definition: IdentifierGroup.h:48
catapult::utils::IdentifierGroup::GroupingKeyType
TGroupingKey GroupingKeyType
Type of grouping key.
Definition: IdentifierGroup.h:34
catapult::utils::IdentifierGroup::add
void add(const TIdentifier &identifier)
Adds identifier to the group.
Definition: IdentifierGroup.h:65
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::utils::IdentifierGroup::remove
void remove(const TIdentifier &identifier)
Removes identifier from the group.
Definition: IdentifierGroup.h:70
catapult::utils::IdentifierGroup::m_identifiers
Identifiers m_identifiers
Definition: IdentifierGroup.h:76
catapult::utils::IdentifierGroup
A group of identifiers that share a common (external) attribute.
Definition: IdentifierGroup.h:28
catapult::utils::IdentifierGroup::m_key
TGroupingKey m_key
Definition: IdentifierGroup.h:75