container:

* dense_hash_map -> dense_map
* dense_hash_set -> dense_set
This commit is contained in:
Michele Caini
2022-01-21 15:40:32 +01:00
parent 530507c36b
commit 7eec610d21
17 changed files with 256 additions and 256 deletions

View File

@@ -120,8 +120,8 @@ if(ENTT_INCLUDE_HEADERS)
INTERFACE
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/config/config.h>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/config/version.h>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/dense_hash_map.hpp>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/dense_hash_set.hpp>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/dense_map.hpp>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/dense_set.hpp>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/fwd.hpp>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/algorithm.hpp>
$<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/any.hpp>

View File

@@ -7,8 +7,8 @@
* [Introduction](#introduction)
* [Containers](#containers)
* [Dense hash map](#dense-hash-map)
* [Dense hash set](#dense-hash-set)
* [Dense map](#dense-map)
* [Dense set](#dense-set)
<!--
@endcond TURN_OFF_DOXYGEN
@@ -31,11 +31,11 @@ guaranteed as usual.
# Containers
## Dense hash map
## Dense map
The dense hash map made available in `EnTT` is a map that aims to return a
The dense map made available in `EnTT` is a hash map that aims to return a
packed array of elements, so as to reduce the number of jumps in memory during
the iteration.<br/>
iterations.<br/>
The implementation is based on _sparse sets_ and each bucket is identified by an
implicit list within the packed array itself.
@@ -43,11 +43,11 @@ The interface is in all respects similar to its counterpart in the standard
library, that is, `std::unordered_map`.<br/>
Therefore, there is no need to go into the API description.
## Dense hash set
## Dense set
The dense hash set made available in `EnTT` is a set that aims to return a
The dense set made available in `EnTT` is a hash set that aims to return a
packed array of elements, so as to reduce the number of jumps in memory during
the iteration.<br/>
iterations.<br/>
The implementation is based on _sparse sets_ and each bucket is identified by an
implicit list within the packed array itself.

View File

@@ -1,5 +1,5 @@
#ifndef ENTT_CONTAINER_DENSE_HASH_MAP_HPP
#define ENTT_CONTAINER_DENSE_HASH_MAP_HPP
#ifndef ENTT_CONTAINER_DENSE_MAP_HPP
#define ENTT_CONTAINER_DENSE_MAP_HPP
#include <algorithm>
#include <cmath>
@@ -28,9 +28,9 @@ namespace entt {
namespace internal {
template<typename Key, typename Type>
struct dense_hash_map_node final {
struct dense_map_node final {
template<typename... Args>
dense_hash_map_node(const std::size_t pos, Args &&...args)
dense_map_node(const std::size_t pos, Args &&...args)
: next{pos},
element{std::forward<Args>(args)...} {}
@@ -39,8 +39,8 @@ struct dense_hash_map_node final {
};
template<typename It>
class dense_hash_map_iterator final {
friend dense_hash_map_iterator<const std::remove_pointer_t<It> *>;
class dense_map_iterator final {
friend dense_map_iterator<const std::remove_pointer_t<It> *>;
using iterator_traits = std::iterator_traits<decltype(std::addressof(std::declval<It>()->element))>;
@@ -51,48 +51,48 @@ public:
using difference_type = typename iterator_traits::difference_type;
using iterator_category = std::random_access_iterator_tag;
dense_hash_map_iterator() ENTT_NOEXCEPT = default;
dense_map_iterator() ENTT_NOEXCEPT = default;
dense_hash_map_iterator(const It iter) ENTT_NOEXCEPT
dense_map_iterator(const It iter) ENTT_NOEXCEPT
: it{iter} {}
template<bool Const = std::is_const_v<std::remove_pointer_t<It>>, typename = std::enable_if_t<Const>>
dense_hash_map_iterator(const dense_hash_map_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
dense_map_iterator(const dense_map_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
: it{other.it} {}
dense_hash_map_iterator &operator++() ENTT_NOEXCEPT {
dense_map_iterator &operator++() ENTT_NOEXCEPT {
return ++it, *this;
}
dense_hash_map_iterator operator++(int) ENTT_NOEXCEPT {
dense_hash_map_iterator orig = *this;
dense_map_iterator operator++(int) ENTT_NOEXCEPT {
dense_map_iterator orig = *this;
return ++(*this), orig;
}
dense_hash_map_iterator &operator--() ENTT_NOEXCEPT {
dense_map_iterator &operator--() ENTT_NOEXCEPT {
return --it, *this;
}
dense_hash_map_iterator operator--(int) ENTT_NOEXCEPT {
dense_hash_map_iterator orig = *this;
dense_map_iterator operator--(int) ENTT_NOEXCEPT {
dense_map_iterator orig = *this;
return operator--(), orig;
}
dense_hash_map_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT {
dense_map_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT {
it += value;
return *this;
}
dense_hash_map_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
dense_hash_map_iterator copy = *this;
dense_map_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
dense_map_iterator copy = *this;
return (copy += value);
}
dense_hash_map_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT {
dense_map_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT {
return (*this += -value);
}
dense_hash_map_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
dense_map_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
return (*this + -value);
}
@@ -109,56 +109,56 @@ public:
}
template<typename ILhs, typename IRhs>
friend auto operator-(const dense_hash_map_iterator<ILhs> &, const dense_hash_map_iterator<IRhs> &) ENTT_NOEXCEPT;
friend auto operator-(const dense_map_iterator<ILhs> &, const dense_map_iterator<IRhs> &) ENTT_NOEXCEPT;
template<typename ILhs, typename IRhs>
friend bool operator==(const dense_hash_map_iterator<ILhs> &, const dense_hash_map_iterator<IRhs> &) ENTT_NOEXCEPT;
friend bool operator==(const dense_map_iterator<ILhs> &, const dense_map_iterator<IRhs> &) ENTT_NOEXCEPT;
template<typename ILhs, typename IRhs>
friend bool operator<(const dense_hash_map_iterator<ILhs> &, const dense_hash_map_iterator<IRhs> &) ENTT_NOEXCEPT;
friend bool operator<(const dense_map_iterator<ILhs> &, const dense_map_iterator<IRhs> &) ENTT_NOEXCEPT;
private:
It it;
};
template<typename ILhs, typename IRhs>
[[nodiscard]] auto operator-(const dense_hash_map_iterator<ILhs> &lhs, const dense_hash_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] auto operator-(const dense_map_iterator<ILhs> &lhs, const dense_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.it - rhs.it;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator==(const dense_hash_map_iterator<ILhs> &lhs, const dense_hash_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const dense_map_iterator<ILhs> &lhs, const dense_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.it == rhs.it;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator!=(const dense_hash_map_iterator<ILhs> &lhs, const dense_hash_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const dense_map_iterator<ILhs> &lhs, const dense_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator<(const dense_hash_map_iterator<ILhs> &lhs, const dense_hash_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator<(const dense_map_iterator<ILhs> &lhs, const dense_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.it < rhs.it;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator>(const dense_hash_map_iterator<ILhs> &lhs, const dense_hash_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator>(const dense_map_iterator<ILhs> &lhs, const dense_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return rhs < lhs;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator<=(const dense_hash_map_iterator<ILhs> &lhs, const dense_hash_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator<=(const dense_map_iterator<ILhs> &lhs, const dense_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs > rhs);
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator>=(const dense_hash_map_iterator<ILhs> &lhs, const dense_hash_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator>=(const dense_map_iterator<ILhs> &lhs, const dense_map_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs < rhs);
}
template<typename It>
class dense_hash_map_local_iterator final {
friend dense_hash_map_local_iterator<const std::remove_pointer_t<It> *>;
class dense_map_local_iterator final {
friend dense_map_local_iterator<const std::remove_pointer_t<It> *>;
using iterator_traits = std::iterator_traits<decltype(std::addressof(std::declval<It>()->element))>;
@@ -169,23 +169,23 @@ public:
using difference_type = typename iterator_traits::difference_type;
using iterator_category = std::forward_iterator_tag;
dense_hash_map_local_iterator() ENTT_NOEXCEPT = default;
dense_map_local_iterator() ENTT_NOEXCEPT = default;
dense_hash_map_local_iterator(It iter, const std::size_t pos) ENTT_NOEXCEPT
dense_map_local_iterator(It iter, const std::size_t pos) ENTT_NOEXCEPT
: it{iter},
offset{pos} {}
template<bool Const = std::is_const_v<std::remove_pointer_t<It>>, typename = std::enable_if_t<Const>>
dense_hash_map_local_iterator(const dense_hash_map_local_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
dense_map_local_iterator(const dense_map_local_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
: it{other.it},
offset{other.offset} {}
dense_hash_map_local_iterator &operator++() ENTT_NOEXCEPT {
dense_map_local_iterator &operator++() ENTT_NOEXCEPT {
return offset = it[offset].next, *this;
}
dense_hash_map_local_iterator operator++(int) ENTT_NOEXCEPT {
dense_hash_map_local_iterator orig = *this;
dense_map_local_iterator operator++(int) ENTT_NOEXCEPT {
dense_map_local_iterator orig = *this;
return ++(*this), orig;
}
@@ -207,12 +207,12 @@ private:
};
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator==(const dense_hash_map_local_iterator<ILhs> &lhs, const dense_hash_map_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const dense_map_local_iterator<ILhs> &lhs, const dense_map_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.index() == rhs.index();
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator!=(const dense_hash_map_local_iterator<ILhs> &lhs, const dense_hash_map_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const dense_map_local_iterator<ILhs> &lhs, const dense_map_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);
}
@@ -237,14 +237,14 @@ template<typename ILhs, typename IRhs>
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
class dense_hash_map {
class dense_map {
static constexpr float default_threshold = 0.875f;
static constexpr std::size_t minimum_capacity = 8u;
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, std::pair<const Key, Type>>);
using node_type = internal::dense_hash_map_node<const Key, Type>;
using node_type = internal::dense_map_node<const Key, Type>;
using sparse_container_type = std::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
using packed_container_type = std::vector<node_type, typename alloc_traits::template rebind_alloc<node_type>>;
@@ -330,24 +330,24 @@ public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Random access iterator type. */
using iterator = internal::dense_hash_map_iterator<typename packed_container_type::pointer>;
using iterator = internal::dense_map_iterator<typename packed_container_type::pointer>;
/*! @brief Constant random access iterator type. */
using const_iterator = internal::dense_hash_map_iterator<typename packed_container_type::const_pointer>;
using const_iterator = internal::dense_map_iterator<typename packed_container_type::const_pointer>;
/*! @brief Forward iterator type. */
using local_iterator = internal::dense_hash_map_local_iterator<typename packed_container_type::pointer>;
using local_iterator = internal::dense_map_local_iterator<typename packed_container_type::pointer>;
/*! @brief Constant forward iterator type. */
using const_local_iterator = internal::dense_hash_map_local_iterator<typename packed_container_type::const_pointer>;
using const_local_iterator = internal::dense_map_local_iterator<typename packed_container_type::const_pointer>;
/*! @brief Default constructor. */
dense_hash_map()
: dense_hash_map(minimum_capacity) {}
dense_map()
: dense_map(minimum_capacity) {}
/**
* @brief Constructs an empty container with a given allocator.
* @param allocator The allocator to use.
*/
explicit dense_hash_map(const allocator_type &allocator)
: dense_hash_map{minimum_capacity, hasher{}, key_equal{}, allocator} {}
explicit dense_map(const allocator_type &allocator)
: dense_map{minimum_capacity, hasher{}, key_equal{}, allocator} {}
/**
* @brief Constructs an empty container with a given allocator and user
@@ -355,8 +355,8 @@ public:
* @param bucket_count Minimal number of buckets.
* @param allocator The allocator to use.
*/
dense_hash_map(const size_type bucket_count, const allocator_type &allocator)
: dense_hash_map{bucket_count, hasher{}, key_equal{}, allocator} {}
dense_map(const size_type bucket_count, const allocator_type &allocator)
: dense_map{bucket_count, hasher{}, key_equal{}, allocator} {}
/**
* @brief Constructs an empty container with a given allocator, hash
@@ -365,8 +365,8 @@ public:
* @param hash Hash function to use.
* @param allocator The allocator to use.
*/
dense_hash_map(const size_type bucket_count, const hasher &hash, const allocator_type &allocator)
: dense_hash_map{bucket_count, hash, key_equal{}, allocator} {}
dense_map(const size_type bucket_count, const hasher &hash, const allocator_type &allocator)
: dense_map{bucket_count, hash, key_equal{}, allocator} {}
/**
* @brief Constructs an empty container with a given allocator, hash
@@ -376,7 +376,7 @@ public:
* @param equal Compare function to use.
* @param allocator The allocator to use.
*/
explicit dense_hash_map(const size_type bucket_count, const hasher &hash = hasher{}, const key_equal &equal = key_equal{}, const allocator_type &allocator = allocator_type())
explicit dense_map(const size_type bucket_count, const hasher &hash = hasher{}, const key_equal &equal = key_equal{}, const allocator_type &allocator = allocator_type())
: sparse{allocator, hash},
packed{allocator, equal},
threshold{default_threshold} {
@@ -387,15 +387,15 @@ public:
* @brief Copy constructor.
* @param other The instance to copy from.
*/
dense_hash_map(const dense_hash_map &other)
: dense_hash_map{other, alloc_traits::select_on_container_copy_construction(other.get_allocator())} {}
dense_map(const dense_map &other)
: dense_map{other, alloc_traits::select_on_container_copy_construction(other.get_allocator())} {}
/**
* @brief Allocator-extended copy constructor.
* @param other The instance to copy from.
* @param allocator The allocator to use.
*/
dense_hash_map(const dense_hash_map &other, const allocator_type &allocator)
dense_map(const dense_map &other, const allocator_type &allocator)
: sparse{sparse_container_type{other.sparse.first(), allocator}, other.sparse.second()},
// cannot copy the container directly due to a nasty issue of apple clang :(
packed{packed_container_type{other.packed.first().begin(), other.packed.first().end(), allocator}, other.packed.second()},
@@ -406,28 +406,28 @@ public:
* @brief Default move constructor.
* @param other The instance to move from.
*/
dense_hash_map(dense_hash_map &&other) ENTT_NOEXCEPT = default;
dense_map(dense_map &&other) ENTT_NOEXCEPT = default;
/**
* @brief Allocator-extended move constructor.
* @param other The instance to move from.
* @param allocator The allocator to use.
*/
dense_hash_map(dense_hash_map &&other, const allocator_type &allocator) ENTT_NOEXCEPT
dense_map(dense_map &&other, const allocator_type &allocator) ENTT_NOEXCEPT
: sparse{sparse_container_type{std::move(other.sparse.first()), allocator}, std::move(other.sparse.second())},
// cannot move the container directly due to a nasty issue of apple clang :(
packed{packed_container_type{std::make_move_iterator(other.packed.first().begin()), std::make_move_iterator(other.packed.first().end()), allocator}, std::move(other.packed.second())},
threshold{other.threshold} {}
/*! @brief Default destructor. */
~dense_hash_map() = default;
~dense_map() = default;
/**
* @brief Copy assignment operator.
* @param other The instance to copy from.
* @return This container.
*/
dense_hash_map &operator=(const dense_hash_map &other) {
dense_map &operator=(const dense_map &other) {
threshold = other.threshold;
sparse.first().clear();
packed.first().clear();
@@ -442,7 +442,7 @@ public:
* @param other The instance to move from.
* @return This container.
*/
dense_hash_map &operator=(dense_hash_map &&other) ENTT_NOEXCEPT = default;
dense_map &operator=(dense_map &&other) ENTT_NOEXCEPT = default;
/**
* @brief Returns the associated allocator.
@@ -686,7 +686,7 @@ public:
* @brief Exchanges the contents with those of a given container.
* @param other Container to exchange the content with.
*/
void swap(dense_hash_map &other) {
void swap(dense_map &other) {
using std::swap;
swap(sparse, other.sparse);
swap(packed, other.packed);

View File

@@ -1,5 +1,5 @@
#ifndef ENTT_CONTAINER_DENSE_HASH_SET_HPP
#define ENTT_CONTAINER_DENSE_HASH_SET_HPP
#ifndef ENTT_CONTAINER_DENSE_SET_HPP
#define ENTT_CONTAINER_DENSE_SET_HPP
#include <algorithm>
#include <cmath>
@@ -28,9 +28,9 @@ namespace entt {
namespace internal {
template<typename Type>
struct dense_hash_set_node final {
struct dense_set_node final {
template<typename... Args>
dense_hash_set_node(const std::size_t pos, Args &&...args)
dense_set_node(const std::size_t pos, Args &&...args)
: next{pos},
element{std::forward<Args>(args)...} {}
@@ -39,8 +39,8 @@ struct dense_hash_set_node final {
};
template<typename It>
class dense_hash_set_iterator final {
friend dense_hash_set_iterator<const std::remove_pointer_t<It> *>;
class dense_set_iterator final {
friend dense_set_iterator<const std::remove_pointer_t<It> *>;
using iterator_traits = std::iterator_traits<decltype(std::addressof(std::as_const(std::declval<It>()->element)))>;
@@ -51,48 +51,48 @@ public:
using difference_type = typename iterator_traits::difference_type;
using iterator_category = std::random_access_iterator_tag;
dense_hash_set_iterator() ENTT_NOEXCEPT = default;
dense_set_iterator() ENTT_NOEXCEPT = default;
dense_hash_set_iterator(const It iter) ENTT_NOEXCEPT
dense_set_iterator(const It iter) ENTT_NOEXCEPT
: it{iter} {}
template<bool Const = std::is_const_v<std::remove_pointer_t<It>>, typename = std::enable_if_t<Const>>
dense_hash_set_iterator(const dense_hash_set_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
dense_set_iterator(const dense_set_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
: it{other.it} {}
dense_hash_set_iterator &operator++() ENTT_NOEXCEPT {
dense_set_iterator &operator++() ENTT_NOEXCEPT {
return ++it, *this;
}
dense_hash_set_iterator operator++(int) ENTT_NOEXCEPT {
dense_hash_set_iterator orig = *this;
dense_set_iterator operator++(int) ENTT_NOEXCEPT {
dense_set_iterator orig = *this;
return ++(*this), orig;
}
dense_hash_set_iterator &operator--() ENTT_NOEXCEPT {
dense_set_iterator &operator--() ENTT_NOEXCEPT {
return --it, *this;
}
dense_hash_set_iterator operator--(int) ENTT_NOEXCEPT {
dense_hash_set_iterator orig = *this;
dense_set_iterator operator--(int) ENTT_NOEXCEPT {
dense_set_iterator orig = *this;
return operator--(), orig;
}
dense_hash_set_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT {
dense_set_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT {
it += value;
return *this;
}
dense_hash_set_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
dense_hash_set_iterator copy = *this;
dense_set_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
dense_set_iterator copy = *this;
return (copy += value);
}
dense_hash_set_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT {
dense_set_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT {
return (*this += -value);
}
dense_hash_set_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
dense_set_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
return (*this + -value);
}
@@ -109,56 +109,56 @@ public:
}
template<typename ILhs, typename IRhs>
friend auto operator-(const dense_hash_set_iterator<ILhs> &, const dense_hash_set_iterator<IRhs> &) ENTT_NOEXCEPT;
friend auto operator-(const dense_set_iterator<ILhs> &, const dense_set_iterator<IRhs> &) ENTT_NOEXCEPT;
template<typename ILhs, typename IRhs>
friend bool operator==(const dense_hash_set_iterator<ILhs> &, const dense_hash_set_iterator<IRhs> &) ENTT_NOEXCEPT;
friend bool operator==(const dense_set_iterator<ILhs> &, const dense_set_iterator<IRhs> &) ENTT_NOEXCEPT;
template<typename ILhs, typename IRhs>
friend bool operator<(const dense_hash_set_iterator<ILhs> &, const dense_hash_set_iterator<IRhs> &) ENTT_NOEXCEPT;
friend bool operator<(const dense_set_iterator<ILhs> &, const dense_set_iterator<IRhs> &) ENTT_NOEXCEPT;
private:
It it;
};
template<typename ILhs, typename IRhs>
[[nodiscard]] auto operator-(const dense_hash_set_iterator<ILhs> &lhs, const dense_hash_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] auto operator-(const dense_set_iterator<ILhs> &lhs, const dense_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.it - rhs.it;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator==(const dense_hash_set_iterator<ILhs> &lhs, const dense_hash_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const dense_set_iterator<ILhs> &lhs, const dense_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.it == rhs.it;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator!=(const dense_hash_set_iterator<ILhs> &lhs, const dense_hash_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const dense_set_iterator<ILhs> &lhs, const dense_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator<(const dense_hash_set_iterator<ILhs> &lhs, const dense_hash_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator<(const dense_set_iterator<ILhs> &lhs, const dense_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.it < rhs.it;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator>(const dense_hash_set_iterator<ILhs> &lhs, const dense_hash_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator>(const dense_set_iterator<ILhs> &lhs, const dense_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return rhs < lhs;
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator<=(const dense_hash_set_iterator<ILhs> &lhs, const dense_hash_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator<=(const dense_set_iterator<ILhs> &lhs, const dense_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs > rhs);
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator>=(const dense_hash_set_iterator<ILhs> &lhs, const dense_hash_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator>=(const dense_set_iterator<ILhs> &lhs, const dense_set_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs < rhs);
}
template<typename It>
class dense_hash_set_local_iterator final {
friend dense_hash_set_local_iterator<const std::remove_pointer_t<It> *>;
class dense_set_local_iterator final {
friend dense_set_local_iterator<const std::remove_pointer_t<It> *>;
using iterator_traits = std::iterator_traits<decltype(std::addressof(std::as_const(std::declval<It>()->element)))>;
@@ -169,23 +169,23 @@ public:
using difference_type = typename iterator_traits::difference_type;
using iterator_category = std::forward_iterator_tag;
dense_hash_set_local_iterator() ENTT_NOEXCEPT = default;
dense_set_local_iterator() ENTT_NOEXCEPT = default;
dense_hash_set_local_iterator(It iter, const std::size_t pos) ENTT_NOEXCEPT
dense_set_local_iterator(It iter, const std::size_t pos) ENTT_NOEXCEPT
: it{iter},
offset{pos} {}
template<bool Const = std::is_const_v<std::remove_pointer_t<It>>, typename = std::enable_if_t<Const>>
dense_hash_set_local_iterator(const dense_hash_set_local_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
dense_set_local_iterator(const dense_set_local_iterator<std::remove_const_t<std::remove_pointer_t<It>> *> &other)
: it{other.it},
offset{other.offset} {}
dense_hash_set_local_iterator &operator++() ENTT_NOEXCEPT {
dense_set_local_iterator &operator++() ENTT_NOEXCEPT {
return offset = it[offset].next, *this;
}
dense_hash_set_local_iterator operator++(int) ENTT_NOEXCEPT {
dense_hash_set_local_iterator orig = *this;
dense_set_local_iterator operator++(int) ENTT_NOEXCEPT {
dense_set_local_iterator orig = *this;
return ++(*this), orig;
}
@@ -207,12 +207,12 @@ private:
};
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator==(const dense_hash_set_local_iterator<ILhs> &lhs, const dense_hash_set_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const dense_set_local_iterator<ILhs> &lhs, const dense_set_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return lhs.index() == rhs.index();
}
template<typename ILhs, typename IRhs>
[[nodiscard]] bool operator!=(const dense_hash_set_local_iterator<ILhs> &lhs, const dense_hash_set_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const dense_set_local_iterator<ILhs> &lhs, const dense_set_local_iterator<IRhs> &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);
}
@@ -236,14 +236,14 @@ template<typename ILhs, typename IRhs>
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
template<typename Type, typename Hash, typename KeyEqual, typename Allocator>
class dense_hash_set {
class dense_set {
static constexpr float default_threshold = 0.875f;
static constexpr std::size_t minimum_capacity = 8u;
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Type>);
using node_type = internal::dense_hash_set_node<Type>;
using node_type = internal::dense_set_node<Type>;
using sparse_container_type = std::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
using packed_container_type = std::vector<node_type, typename alloc_traits::template rebind_alloc<node_type>>;
@@ -335,24 +335,24 @@ public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Random access iterator type. */
using iterator = internal::dense_hash_set_iterator<typename packed_container_type::pointer>;
using iterator = internal::dense_set_iterator<typename packed_container_type::pointer>;
/*! @brief Constant random access iterator type. */
using const_iterator = internal::dense_hash_set_iterator<typename packed_container_type::const_pointer>;
using const_iterator = internal::dense_set_iterator<typename packed_container_type::const_pointer>;
/*! @brief Forward iterator type. */
using local_iterator = internal::dense_hash_set_local_iterator<typename packed_container_type::pointer>;
using local_iterator = internal::dense_set_local_iterator<typename packed_container_type::pointer>;
/*! @brief Constant forward iterator type. */
using const_local_iterator = internal::dense_hash_set_local_iterator<typename packed_container_type::const_pointer>;
using const_local_iterator = internal::dense_set_local_iterator<typename packed_container_type::const_pointer>;
/*! @brief Default constructor. */
dense_hash_set()
: dense_hash_set(minimum_capacity) {}
dense_set()
: dense_set(minimum_capacity) {}
/**
* @brief Constructs an empty container with a given allocator.
* @param allocator The allocator to use.
*/
explicit dense_hash_set(const allocator_type &allocator)
: dense_hash_set{minimum_capacity, hasher{}, key_equal{}, allocator} {}
explicit dense_set(const allocator_type &allocator)
: dense_set{minimum_capacity, hasher{}, key_equal{}, allocator} {}
/**
* @brief Constructs an empty container with a given allocator and user
@@ -360,8 +360,8 @@ public:
* @param bucket_count Minimal number of buckets.
* @param allocator The allocator to use.
*/
dense_hash_set(const size_type bucket_count, const allocator_type &allocator)
: dense_hash_set{bucket_count, hasher{}, key_equal{}, allocator} {}
dense_set(const size_type bucket_count, const allocator_type &allocator)
: dense_set{bucket_count, hasher{}, key_equal{}, allocator} {}
/**
* @brief Constructs an empty container with a given allocator, hash
@@ -370,8 +370,8 @@ public:
* @param hash Hash function to use.
* @param allocator The allocator to use.
*/
dense_hash_set(const size_type bucket_count, const hasher &hash, const allocator_type &allocator)
: dense_hash_set{bucket_count, hash, key_equal{}, allocator} {}
dense_set(const size_type bucket_count, const hasher &hash, const allocator_type &allocator)
: dense_set{bucket_count, hash, key_equal{}, allocator} {}
/**
* @brief Constructs an empty container with a given allocator, hash
@@ -381,7 +381,7 @@ public:
* @param equal Compare function to use.
* @param allocator The allocator to use.
*/
explicit dense_hash_set(const size_type bucket_count, const hasher &hash = hasher{}, const key_equal &equal = key_equal{}, const allocator_type &allocator = allocator_type())
explicit dense_set(const size_type bucket_count, const hasher &hash = hasher{}, const key_equal &equal = key_equal{}, const allocator_type &allocator = allocator_type())
: sparse{allocator, hash},
packed{allocator, equal},
threshold{default_threshold} {
@@ -392,15 +392,15 @@ public:
* @brief Copy constructor.
* @param other The instance to copy from.
*/
dense_hash_set(const dense_hash_set &other)
: dense_hash_set{other, alloc_traits::select_on_container_copy_construction(other.get_allocator())} {}
dense_set(const dense_set &other)
: dense_set{other, alloc_traits::select_on_container_copy_construction(other.get_allocator())} {}
/**
* @brief Allocator-extended copy constructor.
* @param other The instance to copy from.
* @param allocator The allocator to use.
*/
dense_hash_set(const dense_hash_set &other, const allocator_type &allocator)
dense_set(const dense_set &other, const allocator_type &allocator)
: sparse{sparse_container_type{other.sparse.first(), allocator}, other.sparse.second()},
// cannot copy the container directly due to a nasty issue of apple clang :(
packed{packed_container_type{other.packed.first().begin(), other.packed.first().end(), allocator}, other.packed.second()},
@@ -411,28 +411,28 @@ public:
* @brief Default move constructor.
* @param other The instance to move from.
*/
dense_hash_set(dense_hash_set &&other) ENTT_NOEXCEPT = default;
dense_set(dense_set &&other) ENTT_NOEXCEPT = default;
/**
* @brief Allocator-extended move constructor.
* @param other The instance to move from.
* @param allocator The allocator to use.
*/
dense_hash_set(dense_hash_set &&other, const allocator_type &allocator) ENTT_NOEXCEPT
dense_set(dense_set &&other, const allocator_type &allocator) ENTT_NOEXCEPT
: sparse{sparse_container_type{std::move(other.sparse.first()), allocator}, std::move(other.sparse.second())},
// cannot move the container directly due to a nasty issue of apple clang :(
packed{packed_container_type{std::make_move_iterator(other.packed.first().begin()), std::make_move_iterator(other.packed.first().end()), allocator}, std::move(other.packed.second())},
threshold{other.threshold} {}
/*! @brief Default destructor. */
~dense_hash_set() = default;
~dense_set() = default;
/**
* @brief Copy assignment operator.
* @param other The instance to copy from.
* @return This container.
*/
dense_hash_set &operator=(const dense_hash_set &other) {
dense_set &operator=(const dense_set &other) {
threshold = other.threshold;
sparse.first().clear();
packed.first().clear();
@@ -447,7 +447,7 @@ public:
* @param other The instance to move from.
* @return This container.
*/
dense_hash_set &operator=(dense_hash_set &&other) ENTT_NOEXCEPT = default;
dense_set &operator=(dense_set &&other) ENTT_NOEXCEPT = default;
/**
* @brief Returns the associated allocator.
@@ -613,7 +613,7 @@ public:
* @brief Exchanges the contents with those of a given container.
* @param other Container to exchange the content with.
*/
void swap(dense_hash_set &other) {
void swap(dense_set &other) {
using std::swap;
swap(sparse, other.sparse);
swap(packed, other.packed);

View File

@@ -11,14 +11,14 @@ template<
typename = std::hash<Key>,
typename = std::equal_to<Key>,
typename = std::allocator<std::pair<const Key, Type>>>
class dense_hash_map;
class dense_map;
template<
typename Type,
typename = std::hash<Type>,
typename = std::equal_to<Type>,
typename = std::allocator<Type>>
class dense_hash_set;
class dense_set;
} // namespace entt

View File

@@ -6,7 +6,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include "../container/dense_hash_map.hpp"
#include "../container/dense_map.hpp"
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../core/utility.hpp"
@@ -478,7 +478,7 @@ public:
}
private:
dense_hash_map<id_type, std::vector<std::pair<std::size_t, bool>>, identity> dependencies;
dense_map<id_type, std::vector<std::pair<std::size_t, bool>>, identity> dependencies;
std::vector<vertex_data> vertices;
};

View File

@@ -10,7 +10,7 @@
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_hash_map.hpp"
#include "../container/dense_map.hpp"
#include "../core/algorithm.hpp"
#include "../core/any.hpp"
#include "../core/fwd.hpp"
@@ -203,7 +203,7 @@ public:
}
private:
dense_hash_map<id_type, basic_any<0u>, identity> data;
dense_map<id_type, basic_any<0u>, identity> data;
};
} // namespace internal
@@ -1451,7 +1451,7 @@ public:
}
private:
dense_hash_map<id_type, std::unique_ptr<base_type>, identity> pools{};
dense_map<id_type, std::unique_ptr<base_type>, identity> pools{};
std::vector<group_data> groups{};
std::vector<entity_type> entities{};
entity_type free_list{tombstone};

View File

@@ -9,7 +9,7 @@
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_hash_map.hpp"
#include "../container/dense_map.hpp"
#include "../core/type_traits.hpp"
#include "component.hpp"
#include "entity.hpp"
@@ -553,7 +553,7 @@ public:
}
private:
dense_hash_map<entity_type, std::pair<entity_type, bool>> remloc;
dense_map<entity_type, std::pair<entity_type, bool>> remloc;
basic_registry<entity_type> *reg;
};

View File

@@ -1,6 +1,6 @@
#include "config/version.h"
#include "container/dense_hash_map.hpp"
#include "container/dense_hash_set.hpp"
#include "container/dense_map.hpp"
#include "container/dense_set.hpp"
#include "core/algorithm.hpp"
#include "core/any.hpp"
#include "core/attribute.h"

View File

@@ -8,8 +8,8 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "../container/dense_hash_map.hpp"
#include "../container/dense_hash_set.hpp"
#include "../container/dense_map.hpp"
#include "../container/dense_set.hpp"
#include "meta.hpp"
#include "type_traits.hpp"
@@ -251,23 +251,23 @@ struct meta_associative_container_traits<std::unordered_set<Key, Args...>>
: internal::basic_meta_associative_container_traits<std::unordered_set<Key, Args...>> {};
/**
* @brief Meta associative container traits for `dense_hash_map`s of any type.
* @brief Meta associative container traits for `dense_map`s of any type.
* @tparam Key The key type of the elements.
* @tparam Type The value type of the elements.
* @tparam Args Other arguments.
*/
template<typename Key, typename Type, typename... Args>
struct meta_associative_container_traits<dense_hash_map<Key, Type, Args...>>
: internal::basic_meta_associative_container_traits<dense_hash_map<Key, Type, Args...>> {};
struct meta_associative_container_traits<dense_map<Key, Type, Args...>>
: internal::basic_meta_associative_container_traits<dense_map<Key, Type, Args...>> {};
/**
* @brief Meta associative container traits for `dense_hash_set`s of any type.
* @brief Meta associative container traits for `dense_set`s of any type.
* @tparam Type The value type of the elements.
* @tparam Args Other arguments.
*/
template<typename Type, typename... Args>
struct meta_associative_container_traits<dense_hash_set<Type, Args...>>
: internal::basic_meta_associative_container_traits<dense_hash_set<Type, Args...>> {};
struct meta_associative_container_traits<dense_set<Type, Args...>>
: internal::basic_meta_associative_container_traits<dense_set<Type, Args...>> {};
} // namespace entt

View File

@@ -4,7 +4,7 @@
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../container/dense_hash_map.hpp"
#include "../container/dense_map.hpp"
#include "../core/fwd.hpp"
#include "../core/utility.hpp"
#include "fwd.hpp"
@@ -272,7 +272,7 @@ public:
}
private:
dense_hash_map<id_type, resource_handle<resource_type>, identity> resources;
dense_map<id_type, resource_handle<resource_type>, identity> resources;
};
} // namespace entt

View File

@@ -7,7 +7,7 @@
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_hash_map.hpp"
#include "../container/dense_map.hpp"
#include "../core/fwd.hpp"
#include "../core/type_info.hpp"
#include "../core/utility.hpp"
@@ -256,7 +256,7 @@ public:
}
private:
dense_hash_map<id_type, std::unique_ptr<basic_pool>, identity> pools;
dense_map<id_type, std::unique_ptr<basic_pool>, identity> pools;
};
} // namespace entt

View File

@@ -9,7 +9,7 @@
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../container/dense_hash_map.hpp"
#include "../container/dense_map.hpp"
#include "../core/fwd.hpp"
#include "../core/type_info.hpp"
#include "../core/utility.hpp"
@@ -308,7 +308,7 @@ public:
}
private:
dense_hash_map<id_type, std::unique_ptr<basic_pool>, identity> pools{};
dense_map<id_type, std::unique_ptr<basic_pool>, identity> pools{};
};
} // namespace entt

View File

@@ -162,8 +162,8 @@ endif()
# Test container
SETUP_BASIC_TEST(dense_hash_map entt/container/dense_hash_map.cpp)
SETUP_BASIC_TEST(dense_hash_set entt/container/dense_hash_set.cpp)
SETUP_BASIC_TEST(dense_map entt/container/dense_map.cpp)
SETUP_BASIC_TEST(dense_set entt/container/dense_set.cpp)
# Test core

View File

@@ -5,7 +5,7 @@
#include <type_traits>
#include <utility>
#include <gtest/gtest.h>
#include <entt/container/dense_hash_map.hpp>
#include <entt/container/dense_map.hpp>
#include <entt/core/memory.hpp>
#include <entt/core/utility.hpp>
@@ -20,7 +20,7 @@ struct transparent_equal_to {
};
TEST(DenseHashMap, Functionalities) {
entt::dense_hash_map<std::size_t, std::size_t, entt::identity, transparent_equal_to> map;
entt::dense_map<std::size_t, std::size_t, entt::identity, transparent_equal_to> map;
ASSERT_NO_THROW([[maybe_unused]] auto alloc = map.get_allocator());
@@ -87,18 +87,18 @@ TEST(DenseHashMap, Functionalities) {
TEST(DenseHashMap, Contructors) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<int, int> map;
entt::dense_map<int, int> map;
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
map = entt::dense_hash_map<int, int>{std::allocator<int>{}};
map = entt::dense_hash_map<int, int>{2u * minimum_bucket_count, std::allocator<float>{}};
map = entt::dense_hash_map<int, int>{4u * minimum_bucket_count, std::hash<int>(), std::allocator<double>{}};
map = entt::dense_map<int, int>{std::allocator<int>{}};
map = entt::dense_map<int, int>{2u * minimum_bucket_count, std::allocator<float>{}};
map = entt::dense_map<int, int>{4u * minimum_bucket_count, std::hash<int>(), std::allocator<double>{}};
map.emplace(3u, 42u);
entt::dense_hash_map<int, int> temp{map, map.get_allocator()};
entt::dense_hash_map<int, int> other{std::move(temp), map.get_allocator()};
entt::dense_map<int, int> temp{map, map.get_allocator()};
entt::dense_map<int, int> other{std::move(temp), map.get_allocator()};
ASSERT_EQ(other.size(), 1u);
ASSERT_EQ(other.size(), 1u);
@@ -107,11 +107,11 @@ TEST(DenseHashMap, Contructors) {
}
TEST(DenseHashMap, Copy) {
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map.max_load_factor(map.max_load_factor() - .05f);
map.emplace(3u, 42u);
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> other{map};
entt::dense_map<std::size_t, std::size_t, entt::identity> other{map};
ASSERT_TRUE(map.contains(3u));
ASSERT_TRUE(other.contains(3u));
@@ -139,11 +139,11 @@ TEST(DenseHashMap, Copy) {
}
TEST(DenseHashMap, Move) {
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map.max_load_factor(map.max_load_factor() - .05f);
map.emplace(3u, 42u);
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> other{std::move(map)};
entt::dense_map<std::size_t, std::size_t, entt::identity> other{std::move(map)};
ASSERT_EQ(map.size(), 0u);
ASSERT_TRUE(other.contains(3u));
@@ -171,13 +171,13 @@ TEST(DenseHashMap, Move) {
}
TEST(DenseHashMap, Iterator) {
using iterator = typename entt::dense_hash_map<int, int>::iterator;
using iterator = typename entt::dense_map<int, int>::iterator;
static_assert(std::is_same_v<iterator::value_type, std::pair<const int, int>>);
static_assert(std::is_same_v<iterator::pointer, std::pair<const int, int> *>);
static_assert(std::is_same_v<iterator::reference, std::pair<const int, int> &>);
entt::dense_hash_map<int, int> map;
entt::dense_map<int, int> map;
map.emplace(3, 42);
iterator end{map.begin()};
@@ -224,13 +224,13 @@ TEST(DenseHashMap, Iterator) {
}
TEST(DenseHashMap, ConstIterator) {
using iterator = typename entt::dense_hash_map<int, int>::const_iterator;
using iterator = typename entt::dense_map<int, int>::const_iterator;
static_assert(std::is_same_v<iterator::value_type, std::pair<const int, int>>);
static_assert(std::is_same_v<iterator::pointer, const std::pair<const int, int> *>);
static_assert(std::is_same_v<iterator::reference, const std::pair<const int, int> &>);
entt::dense_hash_map<int, int> map;
entt::dense_map<int, int> map;
map.emplace(3, 42);
iterator cend{map.cbegin()};
@@ -277,11 +277,11 @@ TEST(DenseHashMap, ConstIterator) {
}
TEST(DenseHashMap, IteratorConversion) {
entt::dense_hash_map<int, int> map;
entt::dense_map<int, int> map;
map.emplace(3, 42);
typename entt::dense_hash_map<int, int>::iterator it = map.begin();
typename entt::dense_hash_map<int, int>::const_iterator cit = it;
typename entt::dense_map<int, int>::iterator it = map.begin();
typename entt::dense_map<int, int>::const_iterator cit = it;
static_assert(std::is_same_v<decltype(*it), std::pair<const int, int> &>);
static_assert(std::is_same_v<decltype(*cit), const std::pair<const int, int> &>);
@@ -302,8 +302,8 @@ TEST(DenseHashMap, IteratorConversion) {
}
TEST(DenseHashMap, Insert) {
entt::dense_hash_map<int, int> map;
typename entt::dense_hash_map<int, int>::iterator it;
entt::dense_map<int, int> map;
typename entt::dense_map<int, int>::iterator it;
bool result;
ASSERT_TRUE(map.empty());
@@ -382,7 +382,7 @@ TEST(DenseHashMap, Insert) {
TEST(DenseHashMap, InsertRehash) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
ASSERT_EQ(map.size(), 0u);
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
@@ -416,7 +416,7 @@ TEST(DenseHashMap, InsertRehash) {
TEST(DenseHashMap, InsertSameBucket) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
for(std::size_t next{}; next < minimum_bucket_count; ++next) {
ASSERT_EQ(map.cbegin(next), map.cend(next));
@@ -435,8 +435,8 @@ TEST(DenseHashMap, InsertSameBucket) {
}
TEST(DenseHashMap, InsertOrAssign) {
entt::dense_hash_map<int, int> map;
typename entt::dense_hash_map<int, int>::iterator it;
entt::dense_map<int, int> map;
typename entt::dense_map<int, int>::iterator it;
bool result;
ASSERT_TRUE(map.empty());
@@ -498,8 +498,8 @@ TEST(DenseHashMap, InsertOrAssign) {
}
TEST(DenseHashMap, Emplace) {
entt::dense_hash_map<int, int> map;
typename entt::dense_hash_map<int, int>::iterator it;
entt::dense_map<int, int> map;
typename entt::dense_map<int, int>::iterator it;
bool result;
ASSERT_TRUE(map.empty());
@@ -585,7 +585,7 @@ TEST(DenseHashMap, Emplace) {
TEST(DenseHashMap, EmplaceRehash) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
ASSERT_EQ(map.size(), 0u);
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
@@ -620,7 +620,7 @@ TEST(DenseHashMap, EmplaceRehash) {
TEST(DenseHashMap, EmplaceSameBucket) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
for(std::size_t next{}; next < minimum_bucket_count; ++next) {
ASSERT_EQ(map.cbegin(next), map.cend(next));
@@ -639,8 +639,8 @@ TEST(DenseHashMap, EmplaceSameBucket) {
}
TEST(DenseHashMap, TryEmplace) {
entt::dense_hash_map<int, int> map;
typename entt::dense_hash_map<int, int>::iterator it;
entt::dense_map<int, int> map;
typename entt::dense_map<int, int>::iterator it;
bool result;
ASSERT_TRUE(map.empty());
@@ -668,7 +668,7 @@ TEST(DenseHashMap, TryEmplace) {
TEST(DenseHashMap, TryEmplaceRehash) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
ASSERT_EQ(map.size(), 0u);
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
@@ -702,7 +702,7 @@ TEST(DenseHashMap, TryEmplaceRehash) {
TEST(DenseHashMap, TryEmplaceSameBucket) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
for(std::size_t next{}; next < minimum_bucket_count; ++next) {
ASSERT_EQ(map.cbegin(next), map.cend(next));
@@ -722,7 +722,7 @@ TEST(DenseHashMap, TryEmplaceSameBucket) {
TEST(DenseHashMap, Erase) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
for(std::size_t next{}, last = minimum_bucket_count + 1u; next < last; ++next) {
map.emplace(next, next);
@@ -772,7 +772,7 @@ TEST(DenseHashMap, Erase) {
TEST(DenseHashMap, EraseFromBucket) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
ASSERT_EQ(map.size(), 0u);
@@ -862,8 +862,8 @@ TEST(DenseHashMap, EraseFromBucket) {
}
TEST(DenseHashMap, Swap) {
entt::dense_hash_map<int, int> map;
entt::dense_hash_map<int, int> other;
entt::dense_map<int, int> map;
entt::dense_map<int, int> other;
map.emplace(0, 1);
@@ -881,7 +881,7 @@ TEST(DenseHashMap, Swap) {
}
TEST(DenseHashMap, Indexing) {
entt::dense_hash_map<int, int> map;
entt::dense_map<int, int> map;
const auto key = 1;
ASSERT_FALSE(map.contains(key));
@@ -897,14 +897,14 @@ TEST(DenseHashMap, Indexing) {
}
TEST(DenseHashMap, LocalIterator) {
using iterator = typename entt::dense_hash_map<std::size_t, std::size_t, entt::identity>::local_iterator;
using iterator = typename entt::dense_map<std::size_t, std::size_t, entt::identity>::local_iterator;
static_assert(std::is_same_v<iterator::value_type, std::pair<const std::size_t, std::size_t>>);
static_assert(std::is_same_v<iterator::pointer, std::pair<const std::size_t, std::size_t> *>);
static_assert(std::is_same_v<iterator::reference, std::pair<const std::size_t, std::size_t> &>);
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map.emplace(3u, 42u);
map.emplace(3u + minimum_bucket_count, 99u);
@@ -925,14 +925,14 @@ TEST(DenseHashMap, LocalIterator) {
}
TEST(DenseHashMap, ConstLocalIterator) {
using iterator = typename entt::dense_hash_map<std::size_t, std::size_t, entt::identity>::const_local_iterator;
using iterator = typename entt::dense_map<std::size_t, std::size_t, entt::identity>::const_local_iterator;
static_assert(std::is_same_v<iterator::value_type, std::pair<const std::size_t, std::size_t>>);
static_assert(std::is_same_v<iterator::pointer, const std::pair<const std::size_t, std::size_t> *>);
static_assert(std::is_same_v<iterator::reference, const std::pair<const std::size_t, std::size_t> &>);
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map.emplace(3u, 42u);
map.emplace(3u + minimum_bucket_count, 99u);
@@ -953,11 +953,11 @@ TEST(DenseHashMap, ConstLocalIterator) {
}
TEST(DenseHashMap, LocalIteratorConversion) {
entt::dense_hash_map<int, int> map;
entt::dense_map<int, int> map;
map.emplace(3, 42);
typename entt::dense_hash_map<int, int>::local_iterator it = map.begin(map.bucket(3));
typename entt::dense_hash_map<int, int>::const_local_iterator cit = it;
typename entt::dense_map<int, int>::local_iterator it = map.begin(map.bucket(3));
typename entt::dense_map<int, int>::const_local_iterator cit = it;
static_assert(std::is_same_v<decltype(*it), std::pair<const int, int> &>);
static_assert(std::is_same_v<decltype(*cit), const std::pair<const int, int> &>);
@@ -973,7 +973,7 @@ TEST(DenseHashMap, LocalIteratorConversion) {
TEST(DenseHashMap, Rehash) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<std::size_t, std::size_t, entt::identity> map;
entt::dense_map<std::size_t, std::size_t, entt::identity> map;
map[32u] = 99u;
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);
@@ -1056,7 +1056,7 @@ TEST(DenseHashMap, Rehash) {
TEST(DenseHashMap, Reserve) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_map<int, int> map;
entt::dense_map<int, int> map;
ASSERT_EQ(map.bucket_count(), minimum_bucket_count);

View File

@@ -5,7 +5,7 @@
#include <type_traits>
#include <utility>
#include <gtest/gtest.h>
#include <entt/container/dense_hash_set.hpp>
#include <entt/container/dense_set.hpp>
#include <entt/core/memory.hpp>
#include <entt/core/utility.hpp>
@@ -20,7 +20,7 @@ struct transparent_equal_to {
};
TEST(DenseHashSet, Functionalities) {
entt::dense_hash_set<std::size_t, entt::identity, transparent_equal_to> set;
entt::dense_set<std::size_t, entt::identity, transparent_equal_to> set;
ASSERT_NO_THROW([[maybe_unused]] auto alloc = set.get_allocator());
@@ -87,18 +87,18 @@ TEST(DenseHashSet, Functionalities) {
TEST(DenseHashSet, Contructors) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<int> set;
entt::dense_set<int> set;
ASSERT_EQ(set.bucket_count(), minimum_bucket_count);
set = entt::dense_hash_set<int>{std::allocator<int>{}};
set = entt::dense_hash_set<int>{2u * minimum_bucket_count, std::allocator<float>{}};
set = entt::dense_hash_set<int>{4u * minimum_bucket_count, std::hash<int>(), std::allocator<double>{}};
set = entt::dense_set<int>{std::allocator<int>{}};
set = entt::dense_set<int>{2u * minimum_bucket_count, std::allocator<float>{}};
set = entt::dense_set<int>{4u * minimum_bucket_count, std::hash<int>(), std::allocator<double>{}};
set.emplace(3);
entt::dense_hash_set<int> temp{set, set.get_allocator()};
entt::dense_hash_set<int> other{std::move(temp), set.get_allocator()};
entt::dense_set<int> temp{set, set.get_allocator()};
entt::dense_set<int> other{std::move(temp), set.get_allocator()};
ASSERT_EQ(other.size(), 1u);
ASSERT_EQ(other.size(), 1u);
@@ -107,11 +107,11 @@ TEST(DenseHashSet, Contructors) {
}
TEST(DenseHashSet, Copy) {
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
set.max_load_factor(set.max_load_factor() - .05f);
set.emplace(3u);
entt::dense_hash_set<std::size_t, entt::identity> other{set};
entt::dense_set<std::size_t, entt::identity> other{set};
ASSERT_TRUE(set.contains(3u));
ASSERT_TRUE(other.contains(3u));
@@ -135,11 +135,11 @@ TEST(DenseHashSet, Copy) {
}
TEST(DenseHashSet, Move) {
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
set.max_load_factor(set.max_load_factor() - .05f);
set.emplace(3u);
entt::dense_hash_set<std::size_t, entt::identity> other{std::move(set)};
entt::dense_set<std::size_t, entt::identity> other{std::move(set)};
ASSERT_EQ(set.size(), 0u);
ASSERT_TRUE(other.contains(3u));
@@ -163,13 +163,13 @@ TEST(DenseHashSet, Move) {
}
TEST(DenseHashSet, Iterator) {
using iterator = typename entt::dense_hash_set<int>::iterator;
using iterator = typename entt::dense_set<int>::iterator;
static_assert(std::is_same_v<iterator::value_type, int>);
static_assert(std::is_same_v<iterator::pointer, const int *>);
static_assert(std::is_same_v<iterator::reference, const int &>);
entt::dense_hash_set<int> set;
entt::dense_set<int> set;
set.emplace(3);
iterator end{set.begin()};
@@ -216,13 +216,13 @@ TEST(DenseHashSet, Iterator) {
}
TEST(DenseHashSet, ConstIterator) {
using iterator = typename entt::dense_hash_set<int>::const_iterator;
using iterator = typename entt::dense_set<int>::const_iterator;
static_assert(std::is_same_v<iterator::value_type, int>);
static_assert(std::is_same_v<iterator::pointer, const int *>);
static_assert(std::is_same_v<iterator::reference, const int &>);
entt::dense_hash_set<int> set;
entt::dense_set<int> set;
set.emplace(3);
iterator cend{set.cbegin()};
@@ -269,11 +269,11 @@ TEST(DenseHashSet, ConstIterator) {
}
TEST(DenseHashSet, IteratorConversion) {
entt::dense_hash_set<int> set;
entt::dense_set<int> set;
set.emplace(3);
typename entt::dense_hash_set<int, int>::iterator it = set.begin();
typename entt::dense_hash_set<int, int>::const_iterator cit = it;
typename entt::dense_set<int, int>::iterator it = set.begin();
typename entt::dense_set<int, int>::const_iterator cit = it;
static_assert(std::is_same_v<decltype(*it), const int &>);
static_assert(std::is_same_v<decltype(*cit), const int &>);
@@ -294,8 +294,8 @@ TEST(DenseHashSet, IteratorConversion) {
}
TEST(DenseHashSet, Insert) {
entt::dense_hash_set<int> set;
typename entt::dense_hash_set<int>::iterator it;
entt::dense_set<int> set;
typename entt::dense_set<int>::iterator it;
bool result;
ASSERT_TRUE(set.empty());
@@ -346,7 +346,7 @@ TEST(DenseHashSet, Insert) {
TEST(DenseHashSet, InsertRehash) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
ASSERT_EQ(set.size(), 0u);
ASSERT_EQ(set.bucket_count(), minimum_bucket_count);
@@ -377,7 +377,7 @@ TEST(DenseHashSet, InsertRehash) {
TEST(DenseHashSet, InsertSameBucket) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
for(std::size_t next{}; next < minimum_bucket_count; ++next) {
ASSERT_EQ(set.cbegin(next), set.cend(next));
@@ -396,8 +396,8 @@ TEST(DenseHashSet, InsertSameBucket) {
}
TEST(DenseHashSet, Emplace) {
entt::dense_hash_set<int> set;
typename entt::dense_hash_set<int>::iterator it;
entt::dense_set<int> set;
typename entt::dense_set<int>::iterator it;
bool result;
ASSERT_TRUE(set.empty());
@@ -440,7 +440,7 @@ TEST(DenseHashSet, Emplace) {
TEST(DenseHashSet, EmplaceRehash) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
ASSERT_EQ(set.size(), 0u);
ASSERT_EQ(set.bucket_count(), minimum_bucket_count);
@@ -472,7 +472,7 @@ TEST(DenseHashSet, EmplaceRehash) {
TEST(DenseHashSet, EmplaceSameBucket) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
for(std::size_t next{}; next < minimum_bucket_count; ++next) {
ASSERT_EQ(set.cbegin(next), set.cend(next));
@@ -492,7 +492,7 @@ TEST(DenseHashSet, EmplaceSameBucket) {
TEST(DenseHashSet, Erase) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
for(std::size_t next{}, last = minimum_bucket_count + 1u; next < last; ++next) {
set.emplace(next);
@@ -542,7 +542,7 @@ TEST(DenseHashSet, Erase) {
TEST(DenseHashSet, EraseFromBucket) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
ASSERT_EQ(set.bucket_count(), minimum_bucket_count);
ASSERT_EQ(set.size(), 0u);
@@ -632,8 +632,8 @@ TEST(DenseHashSet, EraseFromBucket) {
}
TEST(DenseHashSet, Swap) {
entt::dense_hash_set<int> set;
entt::dense_hash_set<int> other;
entt::dense_set<int> set;
entt::dense_set<int> other;
set.emplace(0);
@@ -651,14 +651,14 @@ TEST(DenseHashSet, Swap) {
}
TEST(DenseHashSet, LocalIterator) {
using iterator = typename entt::dense_hash_set<std::size_t, entt::identity>::local_iterator;
using iterator = typename entt::dense_set<std::size_t, entt::identity>::local_iterator;
static_assert(std::is_same_v<iterator::value_type, std::size_t>);
static_assert(std::is_same_v<iterator::pointer, const std::size_t *>);
static_assert(std::is_same_v<iterator::reference, const std::size_t &>);
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
set.emplace(3u);
set.emplace(3u + minimum_bucket_count);
@@ -679,14 +679,14 @@ TEST(DenseHashSet, LocalIterator) {
}
TEST(DenseHashSet, ConstLocalIterator) {
using iterator = typename entt::dense_hash_set<std::size_t, entt::identity>::const_local_iterator;
using iterator = typename entt::dense_set<std::size_t, entt::identity>::const_local_iterator;
static_assert(std::is_same_v<iterator::value_type, std::size_t>);
static_assert(std::is_same_v<iterator::pointer, const std::size_t *>);
static_assert(std::is_same_v<iterator::reference, const std::size_t &>);
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
set.emplace(3u);
set.emplace(3u + minimum_bucket_count);
@@ -707,11 +707,11 @@ TEST(DenseHashSet, ConstLocalIterator) {
}
TEST(DenseHashSet, LocalIteratorConversion) {
entt::dense_hash_set<int> set;
entt::dense_set<int> set;
set.emplace(3);
typename entt::dense_hash_set<int>::local_iterator it = set.begin(set.bucket(3));
typename entt::dense_hash_set<int>::const_local_iterator cit = it;
typename entt::dense_set<int>::local_iterator it = set.begin(set.bucket(3));
typename entt::dense_set<int>::const_local_iterator cit = it;
static_assert(std::is_same_v<decltype(*it), const int &>);
static_assert(std::is_same_v<decltype(*cit), const int &>);
@@ -727,7 +727,7 @@ TEST(DenseHashSet, LocalIteratorConversion) {
TEST(DenseHashSet, Rehash) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<std::size_t, entt::identity> set;
entt::dense_set<std::size_t, entt::identity> set;
set.emplace(32u);
ASSERT_EQ(set.bucket_count(), minimum_bucket_count);
@@ -802,7 +802,7 @@ TEST(DenseHashSet, Rehash) {
TEST(DenseHashSet, Reserve) {
static constexpr std::size_t minimum_bucket_count = 8u;
entt::dense_hash_set<int> set;
entt::dense_set<int> set;
ASSERT_EQ(set.bucket_count(), minimum_bucket_count);

View File

@@ -275,8 +275,8 @@ TEST_F(MetaContainer, StdSet) {
ASSERT_EQ(view.size(), 0u);
}
TEST_F(MetaContainer, DenseHashMap) {
entt::dense_hash_map<int, char> map{};
TEST_F(MetaContainer, DenseMap) {
entt::dense_map<int, char> map{};
auto any = entt::forward_as_meta(map);
auto view = any.as_associative_container();
@@ -322,8 +322,8 @@ TEST_F(MetaContainer, DenseHashMap) {
ASSERT_EQ(view.size(), 0u);
}
TEST_F(MetaContainer, DenseHashSet) {
entt::dense_hash_set<int> set{};
TEST_F(MetaContainer, DenseSet) {
entt::dense_set<int> set{};
auto any = entt::forward_as_meta(set);
auto view = any.as_associative_container();