__GNU_PBDS::GP_HASH_TABLE(3cxx)

πŸ’– bestie's guide to __gnu_pbds::gp_hash_table (3cxx manual page) πŸ’–

🌸 NAME 🌸

okay so the NAME line is this absolute unit of a template signature, and we are keeping every character exactly:

__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >

✨ SYNOPSIS ✨

bestie, it all starts with this include:

#include <assoc_container.hpp>

and it Inherits this exact thing:

Inherits __gnu_pbds::basic_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, Tag, Policy_Tl, _Alloc >.

πŸŽ€ Public Types πŸŽ€

  • typedef Comb_Probe_Fn comb_probe_fn
  • typedef gp_hash_tag container_category
  • typedef Eq_Fn eq_fn
  • typedef Hash_Fn hash_fn
  • typedef Probe_Fn probe_fn
  • typedef Resize_Policy resize_policy

πŸ’… Public Member Functions πŸ’…

  • gp_hash_table () β€” Default constructor.
  • gp_hash_table (const gp_hash_table &other) β€” exactly as listed; the source doesn't give this one an extra one-liner.
  • gp_hash_table (const hash_fn &h) β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object.
  • gp_hash_table (const hash_fn &h, const eq_fn &e) β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object, and r_eq_fn will be copied by the eq_fn object of the container object.
  • gp_hash_table (const hash_fn &h, const eq_fn &e, const comb_probe_fn &cp) β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, and r_comb_probe_fn will be copied by the comb_probe_fn object of the container object.
  • gp_hash_table (const hash_fn &h, const eq_fn &e, const comb_probe_fn &cp, const probe_fn &p) β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, r_comb_probe_fn will be copied by the comb_probe_fn object of the container object, and r_probe_fn will be copied by the probe_fn object of the container object.
  • gp_hash_table (const hash_fn &h, const eq_fn &e, const comb_probe_fn &cp, const probe_fn &p, const resize_policy &rp) β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, r_comb_probe_fn will be copied by the comb_probe_fn object of the container object, r_probe_fn will be copied by the probe_fn object of the container object, and r_resize_policy will be copied by the Resize_Policy object of the container object.
  • template<typename It > gp_hash_table (It first, It last) β€” Constructor taking __iterators to a range of value_types. The value_types between first_it and last_it will be inserted into the container object.
  • template<typename It > gp_hash_table (It first, It last, const hash_fn &h) β€” Constructor taking __iterators to a range of value_types and some policy objects. The value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object.
  • template<typename It > gp_hash_table (It first, It last, const hash_fn &h, const eq_fn &e) β€” Constructor taking __iterators to a range of value_types and some policy objects. The value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, and r_eq_fn will be copied by the eq_fn object of the container object.
  • template<typename It > gp_hash_table (It first, It last, const hash_fn &h, const eq_fn &e, const comb_probe_fn &cp) β€” Constructor taking __iterators to a range of value_types and some policy objects. The value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, and r_comb_probe_fn will be copied by the comb_probe_fn object of the container object.
  • template<typename It > gp_hash_table (It first, It last, const hash_fn &h, const eq_fn &e, const comb_probe_fn &cp, const probe_fn &p) β€” Constructor taking __iterators to a range of value_types and some policy objects. The value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, r_comb_probe_fn will be copied by the comb_probe_fn object of the container object, and r_probe_fn will be copied by the probe_fn object of the container object.
  • template<typename It > gp_hash_table (It first, It last, const hash_fn &h, const eq_fn &e, const comb_probe_fn &cp, const probe_fn &p, const resize_policy &rp) β€” Constructor taking __iterators to a range of value_types and some policy objects. The value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, r_comb_probe_fn will be copied by the comb_probe_fn object of the container object, r_probe_fn will be copied by the probe_fn object of the container object, and r_resize_policy will be copied by the resize_policy object of the container object.
  • gp_hash_table & operator= (const gp_hash_table &other) β€” exactly as listed.
  • void swap (gp_hash_table &other) β€” exactly as listed.

πŸ’– Detailed Description πŸ’–

template<typename Key , typename Mapped , typename Hash_Fn  = typename detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  = detail::default_comb_hash_fn::type, typename Probe_Fn  = typename detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  = typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool Store_Hash = detail::default_store_hash, typename _Alloc  = std::allocator<char>>
class __gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >

A general-probing hash-based associative container.

🌈 Template Parameters 🌈

  • Key β€” Key type.
  • Mapped β€” Map type.
  • Hash_Fn β€” Hashing functor.
  • Eq_Fn β€” Equal functor.
  • Comb_Probe_Fn β€” Combining probe functor. If Hash_Fn is not null_type, then this is the ranged-probe functor; otherwise, this is the range-hashing functor. XXX See Design::Hash-Based Containers::Hash Policies.
  • Probe_Fn β€” Probe functor.
  • Resize_Policy β€” Resizes hash.
  • Store_Hash β€” Indicates whether the hash value will be stored along with each key. If Hash_Fn is null_type, then the container will not compile if this value is true.
  • _Alloc β€” Allocator type.
🚨 real talk: that Store_Hash line is a hard compile-time no if Hash_Fn is null_type and Store_Hash is true. Not a vibe, bestie.

Base tag choices are: gp_hash_tag.

Base is basic_hash_table.


πŸ”₯ Constructor & Destructor Documentation πŸ”₯

every constructor doc below is wrapped in this exact template head (same one every time, fr fr):

template<typename Key , typename Mapped , typename Hash_Fn  = typename detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  = detail::default_comb_hash_fn::type, typename Probe_Fn  = typename detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  = typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool Store_Hash = detail::default_store_hash, typename _Alloc  = std::allocator<char>>
  • __gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table () [inline] β€” Default constructor.
  • __gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (const hash_fn & h) [inline] β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object.
  • __gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (const hash_fn & h, const eq_fn & e) [inline] β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object, and r_eq_fn will be copied by the eq_fn object of the container object.
  • __gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (const hash_fn & h, const eq_fn & e, const comb_probe_fn & cp) [inline] β€” Constructor taking some policy objects. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, and r_comb_probe_fn will be copied by the comb_probe_fn object of the container object.

okay so the constructor list keeps going, and honestly each one is just β€œbuild a gp_hash_table and copy these policy objects into it” with different amounts of stuff. here’s the full lineup, no skips, no cap πŸ’…

tiny heads up: the docs keep saying r_hash_fn, r_eq_fn, etc. even when the actual parameter names are h, e, cp, p, rp. don’t let that jump-scare you 🫢

1. the four-policy constructor πŸŽ€

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (const hash_fn & h, const eq_fn & e, const comb_probe_fn & cp, const probe_fn & p) [inline]

constructor taking some policy objects. r_hash_fn gets copied by the hash_fn object of the container object, r_eq_fn gets copied by the eq_fn object of the container object, r_comb_probe_fn gets copied by the comb_probe_fn object of the container object, and r_probe_fn gets copied by the probe_fn object of the container object. it’s giving β€œpass me your policies, i’ll keep them safe” ✨

2. the five-policy constructor with a resize policy πŸ¦‹

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (const hash_fn & h, const eq_fn & e, const comb_probe_fn & cp, const probe_fn & p, const resize_policy & rp) [inline]

constructor taking some policy objects. r_hash_fn gets copied by the hash_fn object of the container object, r_eq_fn gets copied by the eq_fn object of the container object, r_comb_probe_fn gets copied by the comb_probe_fn object of the container object, r_probe_fn gets copied by the probe_fn object of the container object, and r_resize_policy gets copied by the Resize_Policy object of the container object. yes bestie, now the resize policy is invited to the group chat too πŸŽ€

3. iterator range constructor, no extra policies 🌸

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
template<typename It >
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (It first, It last) [inline]

constructor taking __iterators to a range of value_types. the value_types between first_it and last_it will be inserted into the container object. literally β€œgive me a range and i’ll stuff it in” energy πŸ’–

4. iterator range plus a hash function 🧚

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
template<typename It >
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (It first, It last, const hash_fn & h) [inline]

constructor taking __iterators to a range of value_types and some policy objects. the value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object. so it’s range insert plus one little policy bestie 🫢

5. iterator range plus hash and equality functions πŸ’œ

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
template<typename It >
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (It first, It last, const hash_fn & h, const eq_fn & e) [inline]

constructor taking __iterators to a range of value_types and some policy objects. the value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, and r_eq_fn will be copied by the eq_fn object of the container object. hash bestie and equality bestie both get copied, slay ✨

6. iterator range plus hash, equality, and comb-probe policies πŸ”₯

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
template<typename It >
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (It first, It last, const hash_fn & h, const eq_fn & e, const comb_probe_fn & cp) [inline]

constructor taking __iterators to a range of value_types and some policy objects. the value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, and r_comb_probe_fn will be copied by the comb_probe_fn object of the container object. three policy besties, all copied, all iconic πŸ’…

7. iterator range plus hash, equality, comb-probe, and probe policies 🌈

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
template<typename It >
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (It first, It last, const hash_fn & h, const eq_fn & e, const comb_probe_fn & cp, const probe_fn & p) [inline]

constructor taking __iterators to a range of value_types and some policy objects. the value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, r_comb_probe_fn will be copied by the comb_probe_fn object of the container object, and r_probe_fn will be copied by the probe_fn object of the container object. the probe policy is here, and it ate 🌟

8. iterator range plus all the policies, including resize πŸ‘‘

template<typename Key , typename Mapped , typename Hash_Fn  = typename
       detail::default_hash_fn<Key>::type, typename Eq_Fn  = typename
       detail::default_eq_fn<Key>::type, typename Comb_Probe_Fn  =
       detail::default_comb_hash_fn::type, typename Probe_Fn  = typename
       detail::default_probe_fn<Comb_Probe_Fn>::type, typename Resize_Policy  =
       typename detail::default_resize_policy<Comb_Probe_Fn>::type, bool
       Store_Hash = detail::default_store_hash, typename _Alloc  =
       std::allocator<char>>
template<typename It >
__gnu_pbds::gp_hash_table< Key, Mapped, Hash_Fn, Eq_Fn, Comb_Probe_Fn, Probe_Fn, Resize_Policy, Store_Hash, _Alloc >::gp_hash_table (It first, It last, const hash_fn & h, const eq_fn & e, const comb_probe_fn & cp, const probe_fn & p, const resize_policy & rp) [inline]

constructor taking __iterators to a range of value_types and some policy objects. the value_types between first_it and last_it will be inserted into the container object. r_hash_fn will be copied by the hash_fn object of the container object, r_eq_fn will be copied by the eq_fn object of the container object, r_comb_probe_fn will be copied by the comb_probe_fn object of the container object, r_probe_fn will be copied by the probe_fn object of the container object, and r_resize_policy will be copied by the resize_policy object of the container object. full policy loadout, no notes, periodt πŸ’–


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code.

and that’s the whole constructor saga, bestie. the footer tag is libst__gnu_pbds::gp_..._Hash, _Alloc >(3cxx) β€” that’s the source/version/date line doing its cryptic little thing. slay, bye ✨🫢