From f9aa86cf4bc7e129383b42ad69bdc6765195226c Mon Sep 17 00:00:00 2001 From: The Fern Date: Thu, 1 Dec 2022 22:57:10 +0100 Subject: [PATCH] Update README --- README.md | 1 + include/ktl/containers/unordered_probe_map.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab788eb..cc7193b 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ This library also contains various containers that are STL compliant. | binary_heap
\ | A binary heap, sorted using the `Comp` and allocated using the given `Alloc` allocator. | `Comp` can be either `std::greater` or `std::less` or some other custom implementation.
A shorthand version of both a min and a max heap can be used, via the `binary_min_heap` and `binary_max_heap` types. | | trivial_array
\ | An array wrapper class, similar to `std::array`, but uses dynamic allocation and is optimized for trivial types. Takes a type `T` and an allocator `Alloc`. | The container uses a straight `memcpy` for most of its operations.
It's not recommended to use this with non-trivial types, eg. types that have custom default, copy or move constructors or custom destructors. | | trivial_vector
\ | A vector class, similar to `std::vector`, but optimized for trivial types. Takes a type `T` and an allocator `Alloc`. | The container uses a straight `memcpy` for most of its operations.
It's not recommended to use this with non-trivial types, eg. types that have custom default, copy or move constructors or custom destructors. | +| unordered_probe_map
| An unordered map class similar to `std::unordered_map`, but optimized for cache locality. | Uses open addressing with linear probing for maximum cache locality.
The container uses a `Hash` struct, `EqualTo` struct and `Alloc` class passed in as template parameters. | ## binary_heap interface | Method | Description | diff --git a/include/ktl/containers/unordered_probe_map.h b/include/ktl/containers/unordered_probe_map.h index a418f4f..10df6e0 100644 --- a/include/ktl/containers/unordered_probe_map.h +++ b/include/ktl/containers/unordered_probe_map.h @@ -233,7 +233,7 @@ namespace ktl V& operator[](const K& index) noexcept { - expand(1); + expand(); pair* block = get_pair(index, m_Begin, m_Mask); @@ -269,7 +269,7 @@ namespace ktl template iterator insert(Key&& index, Value&& value) noexcept { - expand(1); + expand(); // Disallow inserting the same key twice // Lookup is more expensive, so only call in debug @@ -359,7 +359,7 @@ namespace ktl } } - void expand(size_t n) + void expand() { if (m_Count >= capacity() / 2) {