blob: d961e1df3f799195064f244b5d30bca7a046fa23 (
plain) (
blame)
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <mutex>
#include <map>
#include <vector>
#include <vespa/vespalib/stllike/string.h>
namespace vespalib::metrics {
// internal
class NameCollection {
private:
using Map = std::map<vespalib::string, size_t>;
mutable std::mutex _lock;
Map _names;
std::vector<Map::const_iterator> _names_by_id;
public:
const vespalib::string &lookup(size_t id) const;
size_t resolve(const vespalib::string& name);
size_t size() const;
NameCollection();
NameCollection(const NameCollection &) = delete;
NameCollection & operator = (const NameCollection &) = delete;
~NameCollection();
static constexpr size_t empty_id = 0;
};
}
|