When capacity is not enough, the insert() method must call not rehash() but reserve().
Detailed Story
The HashBuckets.reserve() method is a method increasing capacity, however, I'd implemented it to increase number of stored elements, too. By such mistake, whenever a new item has been inserted, length of buckets would be increased by square.
However, there was the second mistake in my implementation. When the HashBuckets.insert() method is called and capacity of the buckets are not enough, the HashBuckets.reserve() should be called to increase its capacity. However, I'd called not HashBuckets.reserve() but HashBuckets.rehash().
By the way, it had been very lucky that such wrong implementations had not affected to the program. As the HashBuckets.insert() method had called HashBuckets.rehash() instead of the HashBuckets.reserve(), error of the HashBuckets.reserve() could not be occured. Also, default max_load_factor of the hash buckets are 1, so reserve(n) and rehash(n) causes the same result. Therefore, until user calls configuration functions of the hash-associative-container like HashMap.reserve() or HashMap.max_load_factor(z), any error could not be occurred. Of course, such custom configuration functions are not called quite a bit. It was really lucky.
Anyway, whether it was luck or not, I must fix those bugs, as soon as possible.
Summary
HashBuckets.reserve()
does not increase its stored elements' countHashBuckets.insert()
callsHashBuckets.reserve()
when its capacity is full.HashBuckets.reserve()
increase its stored elements' countHashBuckets.insert()
callsHashBuckets.rehash()
when its capacity is full.Code occuring the bug
https://github.com/samchon/tstl/blob/b8502f7473df3c303b2090f00212d03ebd18473e/src/internal/hash/HashBuckets.ts#L59-L65
The
reserve()
method must not increase its stored elements' size.https://github.com/samchon/tstl/blob/b8502f7473df3c303b2090f00212d03ebd18473e/src/internal/hash/HashBuckets.ts#L106-L114
When capacity is not enough, the
insert()
method must call notrehash()
butreserve()
.Detailed Story
The
HashBuckets.reserve()
method is a method increasing capacity, however, I'd implemented it to increase number of stored elements, too. By such mistake, whenever a new item has been inserted, length of buckets would be increased by square.However, there was the second mistake in my implementation. When the
HashBuckets.insert()
method is called and capacity of the buckets are not enough, theHashBuckets.reserve()
should be called to increase its capacity. However, I'd called notHashBuckets.reserve()
butHashBuckets.rehash()
.By the way, it had been very lucky that such wrong implementations had not affected to the program. As the
HashBuckets.insert()
method had calledHashBuckets.rehash()
instead of theHashBuckets.reserve()
, error of theHashBuckets.reserve()
could not be occured. Also, defaultmax_load_factor
of the hash buckets are 1, soreserve(n)
andrehash(n)
causes the same result. Therefore, until user calls configuration functions of the hash-associative-container likeHashMap.reserve()
orHashMap.max_load_factor(z)
, any error could not be occurred. Of course, such custom configuration functions are not called quite a bit. It was really lucky.Anyway, whether it was luck or not, I must fix those bugs, as soon as possible.