34 return (
x & (
x - 1)) == 0;
56 template<
typename IntT>
inline constexpr IntT
ceil_division(
const IntT
x,
const IntT
y)
60 return x /
y + ((
x %
y) != 0);
63 template<
typename IntT>
inline constexpr IntT
floor_division(
const IntT
x,
const IntT
y)
84 static_cast<uint64_t>(denominator)));
89 const int64_t max_load_factor_numerator,
90 const int64_t max_load_factor_denominator)
93 min_usable_slots, max_load_factor_numerator, max_load_factor_denominator));
113 : numerator_(numerator), denominator_(denominator)
127 total_slots =
std::max(total_slots, min_total_slots);
129 total_slots, numerator_, denominator_);
132 *r_total_slots = total_slots;
133 *r_usable_slots = usable_slots;
191 return key == EmptyValue;
199 return key == RemovedValue;
207 return key != EmptyValue && key != RemovedValue;
262 float average_collisions_;
267 float removed_load_factor_;
270 const void *address_;
282 template<
typename HashTable,
typename Keys>
285 total_collisions_ = 0;
286 size_ = hash_table.size();
287 capacity_ = hash_table.capacity();
288 removed_amount_ = hash_table.removed_amount();
289 size_per_element_ = hash_table.size_per_element();
290 size_in_bytes_ = hash_table.size_in_bytes();
291 address_ =
static_cast<const void *
>(&hash_table);
293 for (
const auto &key : keys) {
294 int64_t collisions = hash_table.count_collisions(key);
295 if (keys_by_collision_count_.
size() <= collisions) {
297 collisions - keys_by_collision_count_.
size() + 1);
299 keys_by_collision_count_[collisions]++;
300 total_collisions_ += collisions;
303 average_collisions_ = (size_ == 0) ? 0 : (
float)total_collisions_ / (
float)size_;
304 load_factor_ = (
float)size_ / (
float)capacity_;
305 removed_load_factor_ = (
float)removed_amount_ / (
float)capacity_;
310 std::cout <<
"Hash Table Stats: " << name <<
"\n";
311 std::cout <<
" Address: " << address_ <<
"\n";
312 std::cout <<
" Total Slots: " << capacity_ <<
"\n";
313 std::cout <<
" Occupied Slots: " << size_ <<
" (" << load_factor_ * 100.0f <<
" %)\n";
314 std::cout <<
" Removed Slots: " << removed_amount_ <<
" (" << removed_load_factor_ * 100.0f
317 char memory_size_str[15];
319 std::cout <<
" Size: ~" << memory_size_str <<
"\n";
320 std::cout <<
" Size per Slot: " << size_per_element_ <<
" bytes\n";
322 std::cout <<
" Average Collisions: " << average_collisions_ <<
"\n";
324 std::cout <<
" " << collision_count
325 <<
" Collisions: " << keys_by_collision_count_[collision_count] <<
"\n";
typedef float(TangentPoint)[2]
MINLINE int is_power_of_2_i(int n)
void BLI_str_format_byte_unit(char dst[15], long long int bytes, bool base_10) ATTR_NONNULL()
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
HashTableStats(const HashTable &hash_table, const Keys &keys)
void print(StringRef name="")
LoadFactor(uint8_t numerator, uint8_t denominator)
static constexpr int64_t compute_total_slots(int64_t min_usable_slots, uint8_t numerator, uint8_t denominator)
void compute_total_and_usable_slots(int64_t min_total_slots, int64_t min_usable_slots, int64_t *r_total_slots, int64_t *r_usable_slots) const
IndexRange index_range() const
void append_n_times(const T &value, const int64_t n)
constexpr IntT floor_division(const IntT x, const IntT y)
constexpr int64_t total_slot_amount_for_usable_slots(const int64_t min_usable_slots, const int64_t max_load_factor_numerator, const int64_t max_load_factor_denominator)
constexpr int64_t power_of_2_max_constexpr(const int64_t x)
constexpr int64_t log2_ceil_constexpr(const int64_t x)
constexpr int64_t log2_floor_constexpr(const int64_t x)
constexpr int64_t ceil_division_by_fraction(const int64_t x, const int64_t numerator, const int64_t denominator)
constexpr int64_t floor_multiplication_with_fraction(const int64_t x, const int64_t numerator, const int64_t denominator)
constexpr IntT ceil_division(const IntT x, const IntT y)
constexpr int64_t is_power_of_2_constexpr(const int64_t x)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
_W64 unsigned int uintptr_t
unsigned __int64 uint64_t
bool operator()(const T1 &a, const T2 &b) const
static bool is_empty(Pointer pointer)
static Pointer get_empty()
static bool is_not_empty_or_removed(Pointer pointer)
static void remove(Pointer &pointer)
static bool is_removed(Pointer pointer)
static bool is_removed(const Key &key)
static bool is_empty(const Key &key)
static void remove(Key &key)
static bool is_not_empty_or_removed(const Key &key)