Move non-template FlatHashTable functions to cpp.
This commit is contained in:
parent
07bb129653
commit
eac8550ec6
@ -96,6 +96,7 @@ set(TDUTILS_SOURCE
|
||||
td/utils/FileLog.cpp
|
||||
td/utils/filesystem.cpp
|
||||
td/utils/find_boundary.cpp
|
||||
td/utils/FlatHashTable.cpp
|
||||
td/utils/Gzip.cpp
|
||||
td/utils/GzipByteFlow.cpp
|
||||
td/utils/Hints.cpp
|
||||
|
25
tdutils/td/utils/FlatHashTable.cpp
Normal file
25
tdutils/td/utils/FlatHashTable.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/bits.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/Random.h"
|
||||
|
||||
namespace td {
|
||||
namespace detail {
|
||||
|
||||
uint32 normalize_flat_hash_table_size(uint32 size) {
|
||||
return td::max(static_cast<uint32>(1) << (32 - count_leading_zeroes32(size)), static_cast<uint32>(8));
|
||||
}
|
||||
|
||||
uint32 get_random_flat_hash_table_bucket(uint32 bucket_count_mask) {
|
||||
return Random::fast_uint32() & bucket_count_mask;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace td
|
@ -6,15 +6,12 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/bits.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/HashTableUtils.h"
|
||||
#include "td/utils/MapNode.h"
|
||||
#include "td/utils/Random.h"
|
||||
#include "td/utils/SetNode.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
@ -22,13 +19,8 @@
|
||||
namespace td {
|
||||
|
||||
namespace detail {
|
||||
inline uint32 normalize_flat_hash_table_size(uint32 size) {
|
||||
return td::max(static_cast<uint32>(1) << (32 - count_leading_zeroes32(size)), static_cast<uint32>(8));
|
||||
}
|
||||
|
||||
inline uint32 get_random_flat_hash_table_bucket(uint32 bucket_count_mask) {
|
||||
return Random::fast_uint32() & bucket_count_mask;
|
||||
}
|
||||
uint32 normalize_flat_hash_table_size(uint32 size);
|
||||
uint32 get_random_flat_hash_table_bucket(uint32 bucket_count_mask);
|
||||
} // namespace detail
|
||||
|
||||
template <class NodeT, class HashT, class EqT>
|
||||
@ -56,7 +48,7 @@ class FlatHashTable {
|
||||
using value_type = typename NodeT::public_type;
|
||||
|
||||
struct Iterator {
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using value_type = FlatHashTable::value_type;
|
||||
using pointer = value_type *;
|
||||
@ -108,7 +100,7 @@ class FlatHashTable {
|
||||
};
|
||||
|
||||
struct ConstIterator {
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using value_type = FlatHashTable::value_type;
|
||||
using pointer = const value_type *;
|
||||
|
Loading…
Reference in New Issue
Block a user