38#include <gtest/gtest.h>
88 auto *bucket =
new Bucket(10);
101 for (
int k : {5, 3, 7, 1, 4, 6, 8})
110 for (
int k : {5, 3, 7, 1, 4, 6, 8})
135 for (
int k = 0;
k < 100; ++
k)
143 for (
int k = 0;
k < 100; ++
k)
155 for (
int k : {1, 2, 3, 4, 5})
158 for (
int k : {1, 2, 3, 4, 5})
170 for (
int k : {1, 3, 5})
201 auto *bucket =
new Bucket(10);
217 for (
int k : {1, 2, 3, 4, 5})
235 for (
int k : {5, 3, 7, 1, 4, 6, 8})
238 for (
int k : {5, 3, 7, 1, 4, 6, 8})
254 for (
int k = 0;
k < 200; ++
k)
260 for (
int k = 0;
k < 180; ++
k)
281 for (
int k : {5, 3, 7, 1, 4, 6, 8})
306 for (
int k : {1, 2, 3, 4, 5})
312 if (it.get_curr()->get_key() == 3)
327 for (
int k : {1, 2, 3, 4, 5})
344 for (
int k : {1, 2, 3})
363 for (
int k : {1, 2, 3})
394 for (
int k : {1, 2, 3})
400 for (
int k : {10, 20})
431 for (
int k = 0;
k < 50; ++
k)
453 for (
int k = 0;
k < 50; ++
k)
466 bool operator()(
int a,
int b)
const {
return (a % 100) == (b % 100); }
470size_t mod_hash(
const int&
k) {
return static_cast<size_t>(std::abs(
k % 100)); }
497 for (
int k : {-5, -3, -1, 0, 1, 3, 5})
502 for (
int k : {-5, -3, -1, 0, 1, 3, 5})
512 auto *bucket =
new Bucket(42);
518 delete table.
remove(bucket);
541 0.8f, 0.4f,
true,
true)),
546 0.5f, 0.5f,
true,
true)),
559 std::mt19937
rng(12345);
560 std::uniform_int_distribution<int> dist(0, 999);
563 for (
int i = 0; i < 500; ++i)
576 for (
int i = 0; i < 200; ++i)
587 for (
int i = 0; i < 200; ++i)
617 for (
int k = 0;
k <
N; ++
k)
623 for (
int k = 0;
k <
N; ++
k)
627 for (
int k = 0;
k <
N;
k += 2)
637 for (
int k = 1;
k <
N;
k += 2)
649 for (
int k : {1, 2, 3, 4, 5})
654 for (
int k : {1, 2, 3, 4, 5})
712 size_t result = table.
resize(1000);
bool has_curr() const noexcept
Return true if the iterator has current item.
T & insert(const T &item)
Insert a new item by copy.
DynList & swap(DynList &l) noexcept
Swap this with l.
Bucket * get_curr_ne() noexcept
long get_pos() const noexcept
Generic linear hash table.
const size_t & capacity() const noexcept
Returns the table capacity.
std::function< size_t(const Key &)> Hash_Fct
The hash function type.
Cmp & get_compare() noexcept
const size_t & size() const noexcept
Returns the number of elements in the table.
bool is_empty() const noexcept
return true is table is empty
void empty() noexcept
Empty the entire table.
const size_t & expansions() const noexcept
Returns the expansion level performed on the table.
float current_alpha() const noexcept
return the current table load
Bucket * remove(Bucket *bucket) noexcept
Remove bucket from table.
BucketType< Key > Bucket
The bucket type.
const size_t & busy_slots() const noexcept
Returns the number of busy slots in the table.
Bucket * insert(Bucket *bucket)
Insert bucket in the table.
Hash_Fct get_hash_fct() const noexcept
void set_hash_fct(Hash_Fct fct) noexcept
Set the internal hash function.
Bucket * search_or_insert(Bucket *bucket)
Bucket * search(const Key &key) const noexcept
Search for key in the linear hash table.
size_t resize(size_t) noexcept
Provided for generic programming compatibility.
size_t size() const noexcept
Count the number of elements of the list.
Bucket with virtual destructor for a hash table with collision resolution by separate chaining.
Bucket without virtual destructor for a hash table with collision resolution by separate chaining.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t mod_hash(const int &k)
LinearHashTable< int > Table
Main namespace for Aleph-w library functions.
const float hash_default_upper_alpha
const float hash_default_lower_alpha
DynList< T > maps(const C &c, Op op)
Classic map operation.
bool operator()(int a, int b) const
size_t custom_hash(const int &key)
Linear hashing with chaining.