Skip to content

Commit 302cbd6

Browse files
committed
Fix typos.
1 parent a5c318d commit 302cbd6

File tree

8 files changed

+48
-48
lines changed

8 files changed

+48
-48
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ A **benchmark** of `tsl::array_map` against other hash maps can be found [here](
3030
`tsl::array_map` tries to have an interface similar to `std::unordered_map`, but some differences exist:
3131
- Iterator invalidation doesn't behave in the same way, any operation modifying the hash table invalidate them (see [API](https://tessil.github.io/array-hash/doc/html/classtsl_1_1array__map.html#details) for details).
3232
- References and pointers to keys or values in the map are invalidated in the same way as iterators to these keys-values.
33-
- Erase operations have an amortized runtime complexity of O(1) for `tsl::array_map`. An erase operation will delete the key immediatly but for the value part of the map, the deletion may be delayed. The destructor of the value is only called when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough. The method `shrink_to_fit` may be called to force the deletion.
34-
- The key and the value are stored separatly and not in a `std::pair<const Key, T>`. Methods like `insert` or `emplace` take the key and the value separatly instead of a `std::pair`. The insert method looks like `std::pair<iterator, bool> insert(const CharT* key, const T& value)` instead of `std::pair<iterator, bool> insert(const std::pair<const Key, T>& value)` (see [API](https://tessil.github.io/array-hash/doc/html/classtsl_1_1array__map.html) for details).
33+
- Erase operations have an amortized runtime complexity of O(1) for `tsl::array_map`. An erase operation will delete the key immediately but for the value part of the map, the deletion may be delayed. The destructor of the value is only called when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough. The method `shrink_to_fit` may be called to force the deletion.
34+
- The key and the value are stored separately and not in a `std::pair<const Key, T>`. Methods like `insert` or `emplace` take the key and the value separately instead of a `std::pair`. The insert method looks like `std::pair<iterator, bool> insert(const CharT* key, const T& value)` instead of `std::pair<iterator, bool> insert(const std::pair<const Key, T>& value)` (see [API](https://tessil.github.io/array-hash/doc/html/classtsl_1_1array__map.html) for details).
3535
- For iterators, `operator*()` and `operator->()` return a reference and a pointer to the value `T` instead of `std::pair<const Key, T>`. For an access to the key string, the `key()` (which returns a `const CharT*`) or `key_sv()` (which returns a `std::basic_string_view<CharT>`) method of the iterator must be called.
3636
- No support for some bucket related methods (like `bucket_size`, `bucket`, ...).
3737

@@ -211,7 +211,7 @@ struct deserializer {
211211
};
212212
```
213213

214-
Note that the implementation leaves binary compatibilty (endianness, float binary representation, size of int, ...) of the types it serializes/deserializes in the hands of the provided function objects if compatibilty is required.
214+
Note that the implementation leaves binary compatibility (endianness, float binary representation, size of int, ...) of the types it serializes/deserializes in the hands of the provided function objects if compatibility is required.
215215

216216
More details regarding the `serialize` and `deserialize` methods can be found in the [API](https://tessil.github.io/array-hash/doc/html/classtsl_1_1array__map.html).
217217

include/tsl/array_growth_policy.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class power_of_two_growth_policy {
5858
*/
5959
explicit power_of_two_growth_policy(std::size_t& min_bucket_count_in_out) {
6060
if(min_bucket_count_in_out > max_bucket_count()) {
61-
throw std::length_error("The hash table exceeds its maxmimum size.");
61+
throw std::length_error("The hash table exceeds its maximum size.");
6262
}
6363

6464
if(min_bucket_count_in_out > 0) {
@@ -83,7 +83,7 @@ class power_of_two_growth_policy {
8383
*/
8484
std::size_t next_bucket_count() const {
8585
if((m_mask + 1) > max_bucket_count() / GrowthFactor) {
86-
throw std::length_error("The hash table exceeds its maxmimum size.");
86+
throw std::length_error("The hash table exceeds its maximum size.");
8787
}
8888

8989
return (m_mask + 1) * GrowthFactor;
@@ -143,7 +143,7 @@ class mod_growth_policy {
143143
public:
144144
explicit mod_growth_policy(std::size_t& min_bucket_count_in_out) {
145145
if(min_bucket_count_in_out > max_bucket_count()) {
146-
throw std::length_error("The hash table exceeds its maxmimum size.");
146+
throw std::length_error("The hash table exceeds its maximum size.");
147147
}
148148

149149
if(min_bucket_count_in_out > 0) {
@@ -160,12 +160,12 @@ class mod_growth_policy {
160160

161161
std::size_t next_bucket_count() const {
162162
if(m_mod == max_bucket_count()) {
163-
throw std::length_error("The hash table exceeds its maxmimum size.");
163+
throw std::length_error("The hash table exceeds its maximum size.");
164164
}
165165

166166
const double next_bucket_count = std::ceil(double(m_mod) * REHASH_SIZE_MULTIPLICATION_FACTOR);
167167
if(!std::isnormal(next_bucket_count)) {
168-
throw std::length_error("The hash table exceeds its maxmimum size.");
168+
throw std::length_error("The hash table exceeds its maximum size.");
169169
}
170170

171171
if(next_bucket_count > double(max_bucket_count())) {
@@ -265,15 +265,15 @@ static constexpr const std::array<std::size_t(*)(std::size_t), TSL_AH_NB_PRIMES>
265265
* Due to the constant variable in the modulo the compiler is able to optimize the operation
266266
* by a series of multiplications, substractions and shifts.
267267
*
268-
* The 'hash % 5' could become something like 'hash - (hash * 0xCCCCCCCD) >> 34) * 5' in a 64 bits environement.
268+
* The 'hash % 5' could become something like 'hash - (hash * 0xCCCCCCCD) >> 34) * 5' in a 64 bits environment.
269269
*/
270270
class prime_growth_policy {
271271
public:
272272
explicit prime_growth_policy(std::size_t& min_bucket_count_in_out) {
273273
auto it_prime = std::lower_bound(detail::PRIMES.begin(),
274274
detail::PRIMES.end(), min_bucket_count_in_out);
275275
if(it_prime == detail::PRIMES.end()) {
276-
throw std::length_error("The hash table exceeds its maxmimum size.");
276+
throw std::length_error("The hash table exceeds its maximum size.");
277277
}
278278

279279
m_iprime = static_cast<unsigned int>(std::distance(detail::PRIMES.begin(), it_prime));
@@ -291,7 +291,7 @@ class prime_growth_policy {
291291

292292
std::size_t next_bucket_count() const {
293293
if(m_iprime + 1 >= detail::PRIMES.size()) {
294-
throw std::length_error("The hash table exceeds its maxmimum size.");
294+
throw std::length_error("The hash table exceeds its maximum size.");
295295
}
296296

297297
return detail::PRIMES[m_iprime + 1];

include/tsl/array_hash.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class array_bucket {
434434
/**
435435
* Append the element 'key' with its potential value at the end of the bucket.
436436
* 'end_of_bucket' should point past the end of the last element in the bucket, end() if the bucket
437-
* was not intiailized yet. You usually get this value from find_or_end_of_bucket.
437+
* was not initialized yet. You usually get this value from find_or_end_of_bucket.
438438
*
439439
* Return the position where the element was actually inserted.
440440
*/
@@ -716,7 +716,7 @@ class value_container {
716716
protected:
717717
static constexpr float VECTOR_GROWTH_RATE = 1.5f;
718718

719-
// TODO use a sparse array? or a std::dequeu
719+
// TODO use a sparse array? or a std::deque
720720
std::vector<T> m_values;
721721
};
722722

@@ -927,7 +927,7 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
927927
Hash(hash),
928928
GrowthPolicy(bucket_count),
929929
m_buckets_data(bucket_count > max_bucket_count()?
930-
throw std::length_error("The map exceeds its maxmimum bucket count."):
930+
throw std::length_error("The map exceeds its maximum bucket count."):
931931
bucket_count),
932932
m_buckets(m_buckets_data.empty()?static_empty_bucket_ptr():m_buckets_data.data()),
933933
m_nb_elements(0)
@@ -1102,7 +1102,7 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
11021102

11031103

11041104
iterator erase(const_iterator pos) {
1105-
if(shoud_clear_old_erased_values()) {
1105+
if(should_clear_old_erased_values()) {
11061106
clear_old_erased_values();
11071107
}
11081108

@@ -1134,7 +1134,7 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
11341134
nb_elements_until_last--;
11351135
}
11361136

1137-
if(shoud_clear_old_erased_values()) {
1137+
if(should_clear_old_erased_values()) {
11381138
clear_old_erased_values();
11391139
}
11401140

@@ -1148,7 +1148,7 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
11481148
}
11491149

11501150
size_type erase(const CharT* key, size_type key_size, std::size_t hash) {
1151-
if(shoud_clear_old_erased_values()) {
1151+
if(should_clear_old_erased_values()) {
11521152
clear_old_erased_values();
11531153
}
11541154

@@ -1411,12 +1411,12 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
14111411

14121412

14131413
template<class U = T, typename std::enable_if<!has_mapped_type<U>::value>::type* = nullptr>
1414-
bool shoud_clear_old_erased_values(float /*threshold*/ = DEFAULT_CLEAR_OLD_ERASED_VALUE_THRESHOLD) const {
1414+
bool should_clear_old_erased_values(float /*threshold*/ = DEFAULT_CLEAR_OLD_ERASED_VALUE_THRESHOLD) const {
14151415
return false;
14161416
}
14171417

14181418
template<class U = T, typename std::enable_if<has_mapped_type<U>::value>::type* = nullptr>
1419-
bool shoud_clear_old_erased_values(float threshold = DEFAULT_CLEAR_OLD_ERASED_VALUE_THRESHOLD) const {
1419+
bool should_clear_old_erased_values(float threshold = DEFAULT_CLEAR_OLD_ERASED_VALUE_THRESHOLD) const {
14201420
if(this->m_values.size() == 0) {
14211421
return false;
14221422
}
@@ -1458,7 +1458,7 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
14581458
}
14591459

14601460
/**
1461-
* Return true if a rehash occured.
1461+
* Return true if a rehash occurred.
14621462
*/
14631463
bool grow_on_high_load() {
14641464
if(size() >= m_load_threshold) {
@@ -1521,7 +1521,7 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
15211521
}
15221522

15231523

1524-
if(shoud_clear_old_erased_values(REHASH_CLEAR_OLD_ERASED_VALUE_THRESHOLD)) {
1524+
if(should_clear_old_erased_values(REHASH_CLEAR_OLD_ERASED_VALUE_THRESHOLD)) {
15251525
clear_old_erased_values();
15261526
}
15271527

@@ -1688,7 +1688,7 @@ class array_hash: private value_container<T>, private Hash, private GrowthPolicy
16881688

16891689

16901690
if(load_factor() > this->max_load_factor()) {
1691-
throw std::runtime_error("Invalid max_load_factor. Check that the serializer and deserializer supports "
1691+
throw std::runtime_error("Invalid max_load_factor. Check that the serializer and deserializer support "
16921692
"floats correctly as they can be converted implicitely to ints.");
16931693
}
16941694
}

include/tsl/array_map.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace tsl {
4444
* will return a pointer to this null-terminated string). Otherwise the null character
4545
* is not stored (which allow an economy of 1 byte per string).
4646
*
47-
* The value `T` must be either nothrow move-constructible, copy-constuctible or both.
47+
* The value `T` must be either nothrow move-constructible, copy-constructible or both.
4848
*
4949
* The size of a key string is limited to `std::numeric_limits<KeySizeT>::max() - 1`.
5050
* That is 65 535 characters by default, but can be raised with the `KeySizeT` template parameter.
@@ -294,7 +294,7 @@ class array_map {
294294

295295

296296
/**
297-
* Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly,
297+
* Erase has an amortized O(1) runtime complexity, but even if it removes the key immediately,
298298
* it doesn't do the same for the associated value T.
299299
*
300300
* T will only be removed when the ratio between the size of the map and
@@ -368,7 +368,7 @@ class array_map {
368368
* @copydoc erase(const_iterator pos)
369369
*
370370
* Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same
371-
* as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
371+
* as hash_function()(key). Useful to speed-up the lookup to the value if you already have the hash.
372372
*/
373373
size_type erase_ks(const CharT* key, size_type key_size, std::size_t precalculated_hash) {
374374
return m_ht.erase(key, key_size, precalculated_hash);
@@ -463,7 +463,7 @@ class array_map {
463463
#endif
464464
/**
465465
* Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same
466-
* as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
466+
* as hash_function()(key). Useful to speed-up the lookup to the value if you already have the hash.
467467
*/
468468
T& at_ks(const CharT* key, size_type key_size, std::size_t precalculated_hash) {
469469
return m_ht.at(key, key_size, precalculated_hash);
@@ -530,7 +530,7 @@ class array_map {
530530
#endif
531531
/**
532532
* Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same
533-
* as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
533+
* as hash_function()(key). Useful to speed-up the lookup to the value if you already have the hash.
534534
*/
535535
size_type count_ks(const CharT* key, size_type key_size, std::size_t precalculated_hash) const {
536536
return m_ht.count(key, key_size, precalculated_hash);
@@ -618,7 +618,7 @@ class array_map {
618618
#endif
619619
/**
620620
* Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same
621-
* as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
621+
* as hash_function()(key). Useful to speed-up the lookup to the value if you already have the hash.
622622
*/
623623
iterator find_ks(const CharT* key, size_type key_size, std::size_t precalculated_hash) {
624624
return m_ht.find(key, key_size, precalculated_hash);
@@ -713,7 +713,7 @@ class array_map {
713713
#endif
714714
/**
715715
* Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same
716-
* as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
716+
* as hash_function()(key). Useful to speed-up the lookup to the value if you already have the hash.
717717
*/
718718
std::pair<iterator, iterator> equal_range_ks(const CharT* key, size_type key_size, std::size_t precalculated_hash) {
719719
return m_ht.equal_range(key, key_size, precalculated_hash);
@@ -768,16 +768,16 @@ class array_map {
768768
* - `template<typename U> void operator()(const U& value);` where the types `std::uint64_t`, `float` and `T` must be supported for U.
769769
* - `void operator()(const CharT* value, std::size_t value_size);`
770770
*
771-
* The implementation leaves binary compatibilty (endianness, IEEE 754 for floats, ...) of the types it serializes
772-
* in the hands of the `Serializer` function object if compatibilty is required.
771+
* The implementation leaves binary compatibility (endianness, IEEE 754 for floats, ...) of the types it serializes
772+
* in the hands of the `Serializer` function object if compatibility is required.
773773
*/
774774
template<class Serializer>
775775
void serialize(Serializer& serializer) const {
776776
m_ht.serialize(serializer);
777777
}
778778

779779
/**
780-
* Deserialize a previouly serialized map through the `deserializer` parameter.
780+
* Deserialize a previously serialized map through the `deserializer` parameter.
781781
*
782782
* The `deserializer` parameter must be a function object that supports the following calls:
783783
* - `template<typename U> U operator()();` where the types `std::uint64_t`, `float` and `T` must be supported for U.
@@ -791,8 +791,8 @@ class array_map {
791791
* The behaviour is undefined if the type `CharT` and `T` of the `array_map` are not the same as the
792792
* types used during serialization.
793793
*
794-
* The implementation leaves binary compatibilty (endianness, IEEE 754 for floats, size of int, ...) of the types it
795-
* deserializes in the hands of the `Deserializer` function object if compatibilty is required.
794+
* The implementation leaves binary compatibility (endianness, IEEE 754 for floats, size of int, ...) of the types it
795+
* deserializes in the hands of the `Deserializer` function object if compatibility is required.
796796
*/
797797
template<class Deserializer>
798798
static array_map deserialize(Deserializer& deserializer, bool hash_compatible = false) {

0 commit comments

Comments
 (0)