mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-30 00:50:38 +08:00
make "forward declare" header and edit README
This commit is contained in:
Vendored
+10
-81
@@ -51,6 +51,7 @@
|
||||
#include "phmap_bits.h"
|
||||
#include "phmap_base.h"
|
||||
#include "phmap_utils.h"
|
||||
#include "phmap_fwd_decl.h"
|
||||
|
||||
#if PHMAP_HAVE_STD_STRING_VIEW
|
||||
#include <string_view>
|
||||
@@ -3994,14 +3995,6 @@ public:
|
||||
// hash_default
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// The hash of an object of type T is computed by using phmap::Hash.
|
||||
template <class T, class E = void>
|
||||
struct HashEq
|
||||
{
|
||||
using Hash = phmap::Hash<T>;
|
||||
using Eq = std::equal_to<T>;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
struct int64_t_hash
|
||||
@@ -4091,13 +4084,6 @@ struct HashEq<std::unique_ptr<T, D>> : HashEq<T*> {};
|
||||
template <class T>
|
||||
struct HashEq<std::shared_ptr<T>> : HashEq<T*> {};
|
||||
|
||||
template <class T>
|
||||
using hash_default_hash = typename container_internal::HashEq<T>::Hash;
|
||||
|
||||
template <class T>
|
||||
using hash_default_eq = typename container_internal::HashEq<T>::Eq;
|
||||
|
||||
|
||||
namespace hashtable_debug_internal {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -4199,10 +4185,7 @@ public:
|
||||
// slots (open, deleted, and empty) within the hash set.
|
||||
// * Returns `void` from the `erase(iterator)` overload.
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>>
|
||||
template <class T, class Hash, class Eq, class Alloc> // default values in phmap_fwd_decl.h
|
||||
class flat_hash_set
|
||||
: public phmap::container_internal::raw_hash_set<
|
||||
phmap::container_internal::FlatHashSetPolicy<T>, Hash, Eq, Alloc>
|
||||
@@ -4262,10 +4245,7 @@ public:
|
||||
// slots (open, deleted, and empty) within the hash map.
|
||||
// * Returns `void` from the `erase(iterator)` overload.
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class K, class V,
|
||||
class Hash = phmap::container_internal::hash_default_hash<K>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<K>,
|
||||
class Alloc = std::allocator<std::pair<const K, V>>>
|
||||
template <class K, class V, class Hash, class Eq, class Alloc> // default values in phmap_fwd_decl.h
|
||||
class flat_hash_map : public phmap::container_internal::raw_hash_map<
|
||||
phmap::container_internal::FlatHashMapPolicy<K, V>,
|
||||
Hash, Eq, Alloc> {
|
||||
@@ -4323,10 +4303,7 @@ public:
|
||||
// slots (open, deleted, and empty) within the hash set.
|
||||
// * Returns `void` from the `erase(iterator)` overload.
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>>
|
||||
template <class T, class Hash, class Eq, class Alloc> // default values in phmap_fwd_decl.h
|
||||
class node_hash_set
|
||||
: public phmap::container_internal::raw_hash_set<
|
||||
phmap::container_internal::NodeHashSetPolicy<T>, Hash, Eq, Alloc>
|
||||
@@ -4384,10 +4361,7 @@ public:
|
||||
// slots (open, deleted, and empty) within the hash map.
|
||||
// * Returns `void` from the `erase(iterator)` overload.
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class Key, class Value,
|
||||
class Hash = phmap::container_internal::hash_default_hash<Key>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<Key>,
|
||||
class Alloc = std::allocator<std::pair<const Key, Value>>>
|
||||
template <class Key, class Value, class Hash, class Eq, class Alloc> // default values in phmap_fwd_decl.h
|
||||
class node_hash_map
|
||||
: public phmap::container_internal::raw_hash_map<
|
||||
phmap::container_internal::NodeHashMapPolicy<Key, Value>, Hash, Eq,
|
||||
@@ -4437,12 +4411,7 @@ public:
|
||||
// -----------------------------------------------------------------------------
|
||||
// phmap::parallel_flat_hash_set
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>,
|
||||
size_t N = 4,
|
||||
class Mutex = phmap::NullMutex>
|
||||
template <class T, class Hash, class Eq, class Alloc, size_t N, class Mutex> // default values in phmap_fwd_decl.h
|
||||
class parallel_flat_hash_set
|
||||
: public phmap::container_internal::parallel_hash_set<
|
||||
N, phmap::container_internal::raw_hash_set, Mutex,
|
||||
@@ -4487,14 +4456,9 @@ public:
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// phmap::parallel_flat_hash_map
|
||||
// phmap::parallel_flat_hash_map - default values in phmap_fwd_decl.h
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class K, class V,
|
||||
class Hash = phmap::container_internal::hash_default_hash<K>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<K>,
|
||||
class Alloc = std::allocator<std::pair<const K, V>>,
|
||||
size_t N = 4, // 2**N submaps
|
||||
class Mutex = phmap::NullMutex> // use phmap::Mutex to enable internal locks
|
||||
template <class K, class V, class Hash, class Eq, class Alloc, size_t N, class Mutex>
|
||||
class parallel_flat_hash_map : public phmap::container_internal::parallel_hash_map<
|
||||
N, phmap::container_internal::raw_hash_set, Mutex,
|
||||
phmap::container_internal::FlatHashMapPolicy<K, V>,
|
||||
@@ -4544,24 +4508,7 @@ public:
|
||||
// -----------------------------------------------------------------------------
|
||||
// phmap::parallel_node_hash_set
|
||||
// -----------------------------------------------------------------------------
|
||||
// An `phmap::node_hash_set<T>` is an unordered associative container which
|
||||
// has been optimized for both speed and memory footprint in most common use
|
||||
// cases. Its interface is similar to that of `std::unordered_set<T>` with the
|
||||
// following notable differences:
|
||||
//
|
||||
// * Supports heterogeneous lookup, through `find()`, `operator[]()` and
|
||||
// `insert()`, provided that the map is provided a compatible heterogeneous
|
||||
// hashing function and equality operator.
|
||||
// * Contains a `capacity()` member function indicating the number of element
|
||||
// slots (open, deleted, and empty) within the hash set.
|
||||
// * Returns `void` from the `erase(iterator)` overload.
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>,
|
||||
size_t N = 4,
|
||||
class Mutex = phmap::NullMutex>
|
||||
template <class T, class Hash, class Eq, class Alloc, size_t N, class Mutex>
|
||||
class parallel_node_hash_set
|
||||
: public phmap::container_internal::parallel_hash_set<
|
||||
N, phmap::container_internal::raw_hash_set, Mutex,
|
||||
@@ -4607,25 +4554,7 @@ public:
|
||||
// -----------------------------------------------------------------------------
|
||||
// phmap::parallel_node_hash_map
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// An `phmap::node_hash_map<K, V>` is an unordered associative container which
|
||||
// has been optimized for both speed and memory footprint in most common use
|
||||
// cases. Its interface is similar to that of `std::unordered_map<K, V>` with
|
||||
// the following notable differences:
|
||||
//
|
||||
// * Supports heterogeneous lookup, through `find()`, `operator[]()` and
|
||||
// `insert()`, provided that the map is provided a compatible heterogeneous
|
||||
// hashing function and equality operator.
|
||||
// * Contains a `capacity()` member function indicating the number of element
|
||||
// slots (open, deleted, and empty) within the hash map.
|
||||
// * Returns `void` from the `erase(iterator)` overload.
|
||||
// -----------------------------------------------------------------------------
|
||||
template <class Key, class Value,
|
||||
class Hash = phmap::container_internal::hash_default_hash<Key>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<Key>,
|
||||
class Alloc = std::allocator<std::pair<const Key, Value>>,
|
||||
size_t N = 4,
|
||||
class Mutex = phmap::NullMutex>
|
||||
template <class Key, class Value, class Hash, class Eq, class Alloc, size_t N, class Mutex>
|
||||
class parallel_node_hash_map
|
||||
: public phmap::container_internal::parallel_hash_map<
|
||||
N, phmap::container_internal::raw_hash_set, Mutex,
|
||||
|
||||
Vendored
+130
@@ -0,0 +1,130 @@
|
||||
#if !defined(phmap_fwd_decl_h_guard_)
|
||||
#define phmap_fwd_decl_h_guard_
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (c) 2019, Gregory Popovitch - greg7mdp@gmail.com
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Includes work from abseil-cpp (https://github.com/abseil/abseil-cpp)
|
||||
// with modifications.
|
||||
//
|
||||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<class> class allocator;
|
||||
template<class T1, class T2> struct pair;
|
||||
}
|
||||
|
||||
namespace phmap {
|
||||
|
||||
template <class T> struct Hash;
|
||||
template <class T> struct EqualTo;
|
||||
|
||||
class NullMutex;
|
||||
|
||||
namespace container_internal {
|
||||
|
||||
// The hash of an object of type T is computed by using phmap::Hash.
|
||||
template <class T, class E = void>
|
||||
struct HashEq
|
||||
{
|
||||
using Hash = phmap::Hash<T>;
|
||||
using Eq = phmap::EqualTo<T>;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
using hash_default_hash = typename container_internal::HashEq<T>::Hash;
|
||||
|
||||
template <class T>
|
||||
using hash_default_eq = typename container_internal::HashEq<T>::Eq;
|
||||
|
||||
} // namespace container_internal
|
||||
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>>
|
||||
class flat_hash_set;
|
||||
|
||||
template <class K, class V,
|
||||
class Hash = phmap::container_internal::hash_default_hash<K>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<K>,
|
||||
class Alloc = std::allocator<std::pair<const K, V>>>
|
||||
class flat_hash_map;
|
||||
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>>
|
||||
class node_hash_set;
|
||||
|
||||
template <class Key, class Value,
|
||||
class Hash = phmap::container_internal::hash_default_hash<Key>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<Key>,
|
||||
class Alloc = std::allocator<std::pair<const Key, Value>>>
|
||||
class node_hash_map;
|
||||
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>,
|
||||
size_t N = 4, // 2**N submaps
|
||||
class Mutex = phmap::NullMutex> // use std::mutex to enable internal locks
|
||||
class parallel_flat_hash_set;
|
||||
|
||||
template <class K, class V,
|
||||
class Hash = phmap::container_internal::hash_default_hash<K>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<K>,
|
||||
class Alloc = std::allocator<std::pair<const K, V>>,
|
||||
size_t N = 4, // 2**N submaps
|
||||
class Mutex = phmap::NullMutex> // use std::mutex to enable internal locks
|
||||
class parallel_flat_hash_map;
|
||||
|
||||
template <class T,
|
||||
class Hash = phmap::container_internal::hash_default_hash<T>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<T>,
|
||||
class Alloc = std::allocator<T>,
|
||||
size_t N = 4, // 2**N submaps
|
||||
class Mutex = phmap::NullMutex> // use std::mutex to enable internal locks
|
||||
class parallel_node_hash_set;
|
||||
|
||||
template <class Key, class Value,
|
||||
class Hash = phmap::container_internal::hash_default_hash<Key>,
|
||||
class Eq = phmap::container_internal::hash_default_eq<Key>,
|
||||
class Alloc = std::allocator<std::pair<const Key, Value>>,
|
||||
size_t N = 4, // 2**N submaps
|
||||
class Mutex = phmap::NullMutex> // use std::mutex to enable internal locks
|
||||
class parallel_node_hash_map;
|
||||
|
||||
|
||||
|
||||
} // namespace phmap
|
||||
|
||||
|
||||
#endif // phmap_fwd_decl_h_guard_
|
||||
Vendored
+9
@@ -44,6 +44,15 @@ namespace phmap
|
||||
template <class T> T phmap_min(T a, T b) { return a < b ? a : b; }
|
||||
template <class T> T phmap_max(T a, T b) { return a >= b ? a : b; }
|
||||
|
||||
template <class T>
|
||||
struct EqualTo
|
||||
{
|
||||
inline size_t operator()(const T& a, const T& b) const
|
||||
{
|
||||
return std::equal_to<T>()(a, b);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Hash
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user