dynarmic/include/mcl/container/detail/meta_byte.hpp
Merry 78bb1d1571 Squashed 'externals/mcl/' changes from 761b7c05e..0172df743
0172df743 CMakeLists: Only add tests if MASTER_PROJECT
52e8dff62 0.1.11
fc8d745cc container: hmap fixups
5b5c0130d memory: Add overaligned_unique_ptr
c7c9bbd17 mcl: Increment version to 0.1.10
678aa32a8 assert: Handle expr strings separately
b38a9d2ef tests: Update to Catch 3.0.1
8aeacfe32 mcl: Increment version to 0.1.9
b468a2ab5 mcl: meta_byte: Split off meta_byte_group
d3ae1ae47 mcl: ihmap: Implement inline variant of hmap
5cbfe6eed mcl: hmap: Split detail into headers
ee7467677 mcl: hmap: Better default hash
f1d902ce9 mcl: hash: Add xmrx
322a221f0 mcl: hmap: Bugfix skip_empty_or_tombstone
689f393f7 mcl: hmap: x64 implementation
fa6ff746a mcl: hmap: Add generic meta_byte_group implementation
91e3073ad mcl: hmap: Add more member functions
4998335a5 mcl: Install only if master project
7ff4d2549 mcl: hmap prototype
416a2c6b5 mcl: clang-format: Adopt WebKit style bracing
d5a46fa70 mcl/assert: Flush stderr
e3b6cc79e externals: Update mcl to 0.1.7
190c68475 mcl: Build as PIC

git-subtree-dir: externals/mcl
git-subtree-split: 0172df74316351868c215f735e5a2538b10d71fb
2022-07-10 10:10:04 +01:00

35 lines
776 B
C++

// This file is part of the mcl project.
// Copyright (c) 2022 merryhime
// SPDX-License-Identifier: MIT
#pragma once
#include "mcl/bitsizeof.hpp"
#include "mcl/stdint.hpp"
namespace mcl::detail {
/// if MSB is 0, this is a full slot. remaining 7 bits is a partial hash of the key.
/// if MSB is 1, this is a non-full slot.
enum class meta_byte : u8 {
empty = 0xff,
tombstone = 0x80,
end_sentinel = 0x88,
};
inline bool is_full(meta_byte mb)
{
return (static_cast<u8>(mb) & 0x80) == 0;
}
inline meta_byte meta_byte_from_hash(size_t hash)
{
return static_cast<meta_byte>(hash >> (bitsizeof<size_t> - 7));
}
inline size_t group_index_from_hash(size_t hash, size_t group_index_mask)
{
return hash & group_index_mask;
}
} // namespace mcl::detail