std::__detail::...2_rehash_policy(3cxx)
π std::__detail::_Power2_rehash_policy π
okay bestie, sit down, because we're talking about a libstdc++ internal β the kind of thing you find in the 3cxx section of the manual, i.e. C++ library docs. she's from <hashtable_policy.h> and she's lowkey iconic. π
β¨ NAME β¨
std::__detail::_Power2_rehash_policy β Rehash policy providing power of 2 bucket numbers. Avoids modulo operations.
that's it, that's the whole vibe. power-of-two buckets so we can dodge the modulo math. no cap. π¦
πΈ SYNOPSIS πΈ
#include <hashtable_policy.h>
π§ Public Types
using __has_load_factor = true_typeβ yes girl, she has a load factor, it's literallytrue_type. πtypedef std::size_t _Stateβ the state type is juststd::size_t. keep it simple bestie.
π Public Member Functions
_Power2_rehash_policy(float __z = 1.0) noexceptβ constructor, takes afloat __zthat defaults to1.0, and she'snoexceptabout it. unbothered. π«Άstd::size_t _M_bkt_for_elements(std::size_t __n) const noexceptβ tells you how many buckets you'd need for__nelements.const,noexcept, queen behavior.std::pair<bool, std::size_t> _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt, std::size_t __n_ins) noexceptβ the big one: do we need to rehash?? returns astd::pair<bool, std::size_t>because of course it does.std::size_t _M_next_bkt(std::size_t __n) noexceptβ next bucket count, pls. π¦void _M_reset() noexceptβ reset her. no args, no drama.void _M_reset(_State __state) noexceptβ reset her to a specific_State __state. π_State _M_state() const noexceptβ read the state back out.const,noexcept, flawless.float max_load_factor() const noexceptβ returns the max load factor as afloat. β
π Public Attributes
float _M_max_load_factorβ the max load factor, just vibing out in public.std::size_t _M_next_resizeβ the next resize threshold. she's watching. π
π Static Public Attributes
static const std::size_t _S_growth_factorβ the growth factor, static andconst, as she should be. π
π Detailed Description π
Rehash policy providing power of 2 bucket numbers. Avoids modulo operations.
fr fr that's the whole point β powers of two let the bucket math skip modulo entirely, which is the kind of optimization that makes you go oh she ate. π₯
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
like, she wasn't even hand-written, Doxygen literally birthed her from the source. main character energy but make it automated. π
and that's the tea, bestie β this page lives in the 3cxx manual, comes to you courtesy of libstdc++ and the Doxygen machine that generated it straight from the source, so go forth and rehash responsibly. mwah. πβ¨π
π¦ where this page comes from
- ubuntu noble: libstdc++-10-doc 10.5.0-4ubuntu2
- ubuntu noble: libstdc++-10-doc 10.5.0-4ubuntu2.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms