47 return (
x & (
x - 1)) == 0;
69 template<
typename IntT>
inline constexpr IntT
ceil_division(
const IntT
x,
const IntT
y)
73 return x /
y + ((
x %
y) != 0);
76 template<
typename IntT>
inline constexpr IntT
floor_division(
const IntT
x,
const IntT
y)
97 static_cast<uint64_t>(denominator)));
101 const int64_t min_usable_slots,
102 const int64_t max_load_factor_numerator,
103 const int64_t max_load_factor_denominator)
106 min_usable_slots, max_load_factor_numerator, max_load_factor_denominator));
126 : numerator_(numerator), denominator_(denominator)
140 total_slots =
std::max(total_slots, min_total_slots);
142 total_slots, numerator_, denominator_);
145 *r_total_slots = total_slots;
146 *r_usable_slots = usable_slots;
204 return key == EmptyValue;
212 return key == RemovedValue;
220 return key != EmptyValue && key != RemovedValue;
275 float average_collisions_;
280 float removed_load_factor_;
283 const void *address_;
295 template<
typename HashTable,
typename Keys>
298 total_collisions_ = 0;
299 size_ = hash_table.size();
300 capacity_ = hash_table.capacity();
301 removed_amount_ = hash_table.removed_amount();
302 size_per_element_ = hash_table.size_per_element();
303 size_in_bytes_ = hash_table.size_in_bytes();
304 address_ =
static_cast<const void *
>(&hash_table);
306 for (
const auto &key : keys) {
307 int64_t collisions = hash_table.count_collisions(key);
308 if (keys_by_collision_count_.
size() <= collisions) {
310 collisions - keys_by_collision_count_.
size() + 1);
312 keys_by_collision_count_[collisions]++;
313 total_collisions_ += collisions;
316 average_collisions_ = (size_ == 0) ? 0 : (
float)total_collisions_ / (
float)size_;
317 load_factor_ = (
float)size_ / (
float)capacity_;
318 removed_load_factor_ = (
float)removed_amount_ / (
float)capacity_;
323 std::cout <<
"Hash Table Stats: " << name <<
"\n";
324 std::cout <<
" Address: " << address_ <<
"\n";
325 std::cout <<
" Total Slots: " << capacity_ <<
"\n";
326 std::cout <<
" Occupied Slots: " << size_ <<
" (" << load_factor_ * 100.0f <<
" %)\n";
327 std::cout <<
" Removed Slots: " << removed_amount_ <<
" (" << removed_load_factor_ * 100.0f
330 char memory_size_str[15];
332 std::cout <<
" Size: ~" << memory_size_str <<
"\n";
333 std::cout <<
" Size per Slot: " << size_per_element_ <<
" bytes\n";
335 std::cout <<
" Average Collisions: " << average_collisions_ <<
"\n";
337 std::cout <<
" " << collision_count
338 <<
" 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, const 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)
_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)