Files
MapLibreParticleLab/include/mbgl/util/string_indexer.hpp
Tim Sylvester 25c1f3c7a6 Rebase fill-extrusion work to eliminate dependence on render target branch (#1618)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Alex Cristici <alex.cristici@gmail.com>
Co-authored-by: mwilsnd <mwilsnd@gmail.com>
Co-authored-by: Stefan Karschti <stefan.karschti@gmail.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
Co-authored-by: Alex Cristici <alex@skoon.energy>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
Co-authored-by: Wei Chen <alanchenboy@gmail.com>
Co-authored-by: Siarhei Fedartsou <siarhei.fedartsou@gmail.com>
Co-authored-by: tdcosta100 <tdcosta100@gmail.com>
2023-09-15 16:02:26 -07:00

49 lines
1.0 KiB
C++

#pragma once
#include <cstdint>
#include <cstddef>
#include <string>
#include <unordered_map>
#include <vector>
#include <mutex>
#include <shared_mutex>
namespace mbgl {
using StringIdentity = size_t;
class StringIndexer {
public:
StringIndexer(StringIndexer const&) = delete;
StringIndexer(StringIndexer&&) = delete;
void operator=(StringIndexer const&) = delete;
static StringIdentity get(const char*);
static StringIdentity get(std::string_view);
static StringIdentity get(const std::string&);
static const std::string& get(const StringIdentity id);
static void clear();
static size_t size();
protected:
StringIndexer();
~StringIndexer() = default;
using MapType = std::unordered_map<std::string, StringIdentity>;
using VectorType = std::vector<std::string>;
static StringIndexer& instance() {
static StringIndexer inst;
return inst;
}
MapType stringToIdentity;
VectorType identityToString;
std::shared_mutex sharedMutex;
};
} // namespace mbgl