1#ifndef SOURCEMETA_BLAZE_BINPACK_ENCODER_CACHE_H_
2#define SOURCEMETA_BLAZE_BINPACK_ENCODER_CACHE_H_
5#ifndef SOURCEMETA_BLAZE_BINPACK_EXPORT
6#include <sourcemeta/blaze/binpack_export.h>
9#include <sourcemeta/core/json.h>
16namespace sourcemeta::blaze {
18class SOURCEMETA_BLAZE_BINPACK_EXPORT BinPackCache {
20 enum class Type : std::uint8_t { Standalone, PrefixLengthVarintPlusOne };
21 auto record(
const sourcemeta::core::JSON::String &value,
22 const std::uint64_t offset,
const Type type) -> void;
23 [[nodiscard]]
auto find(
const sourcemeta::core::JSON::String &value,
24 const Type type)
const
25 -> std::optional<std::uint64_t>;
29 auto remove_oldest() -> void;
37#pragma warning(disable : 4251 4275)
39 std::uint64_t byte_size_{0};
40 using Entry = std::pair<sourcemeta::core::JSON::String, Type>;
41 std::map<Entry, std::uint64_t> data_;
42 std::map<std::uint64_t, std::reference_wrapper<const Entry>> order_;
44#pragma warning(default : 4251 4275)