[kutil] Add kutil::map hash map

Added the kutil::map collection, an open addressing, robinhood hash map
with backwards shift deletes. Also added hash.h with templated
implementations of the FNV-1a 64 bit hash function, and pulled the log2
function out of the heap_allocator code into the new util.h.
This commit is contained in:
2020-09-12 00:31:38 -07:00
parent 71cd7af17b
commit 1238608430
7 changed files with 345 additions and 9 deletions

View File

@@ -1,7 +1,8 @@
#include <stdint.h>
#include "kutil/assert.h"
#include "kutil/memory.h"
#include "kutil/heap_allocator.h"
#include "kutil/memory.h"
#include "kutil/util.h"
namespace kutil {
@@ -77,8 +78,7 @@ heap_allocator::allocate(size_t length)
if (length == 0)
return nullptr;
const unsigned clz = __builtin_clzll(total - 1);
unsigned order = 64 - clz;
unsigned order = log2(total);
if (order < min_order)
order = min_order;