blob: 1308f5caf021a0687668a29072ee81217e114b29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#pragma once
#include "indexer/classificator.hpp"
#include "indexer/search_string_utils.hpp"
#include "base/macros.hpp"
#include "base/string_utils.hpp"
#include "std/algorithm.hpp"
#include "std/cstdint.hpp"
#include "std/map.hpp"
namespace search
{
class CategoriesSet
{
public:
CategoriesSet() : m_classificator(classif()) {}
void Add(uint32_t type)
{
uint32_t const index = m_classificator.GetIndexForType(type);
m_categories[FeatureTypeToString(index)] = type;
}
template <typename TFn>
void ForEach(TFn && fn) const
{
for (auto const & p : m_categories)
fn(p.first, p.second);
}
bool HasKey(strings::UniString const & key) const
{
return m_categories.count(key) != 0;
}
private:
Classificator const & m_classificator;
map<strings::UniString, uint32_t> m_categories;
DISALLOW_COPY_AND_MOVE(CategoriesSet);
};
} // namespace search
|