Skip to content

Commit 0966bd8

Browse files
committed
Update README.md. Fix example.
1 parent 05bc40c commit 0966bd8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Two classes are provided: `tsl::ordered_map` and `tsl::ordered_set`.
2020
- Values are stored in the same order as the insertion order. The library provides a direct access to the underlying structure which stores the values.
2121
- O(1) average time complexity for lookups with performances similar to `std::unordered_map` but with faster insertions and reduced memory usage (see [benchmark](https://tessil.github.io/2016/08/29/benchmark-hopscotch-map.html) for details).
2222
- Provide random access iterators and also reverse iterators.
23-
- Support for heterogeneous lookups allowing the usage of `find` with a type different than `Key` (e.g. if you have a map that uses `std::unique_ptr<foo>` as key, you could use a `foo*` or a `std::uintptr_t` as key parameter to `find` without constructing a `std::unique_ptr<foo>`, see [example](#heterogeneous-lookups)).
23+
- Support for heterogeneous lookups allowing the usage of `find` with a type different than `Key` (e.g. if you have a map that uses `std::unique_ptr<foo>` as key, you can use a `foo*` or a `std::uintptr_t` as key parameter to `find` without constructing a `std::unique_ptr<foo>`, see [example](#heterogeneous-lookups)).
2424
- If the hash is known before a lookup, it is possible to pass it as parameter to speed-up the lookup (see `precalculated_hash` parameter in [API](https://tessil.github.io/ordered-map/classtsl_1_1ordered__map.html#a7fcde27edc6697a0b127f4b1aefa8a7d)).
2525
- The library can be used with exceptions disabled (through `-fno-exceptions` option on Clang and GCC, without an `/EH` option on MSVC or simply by defining `TSL_NO_EXCEPTIONS`). `std::terminate` is used in replacement of the `throw` instruction when exceptions are disabled.
2626
- API closely similar to `std::unordered_map` and `std::unordered_set`.
@@ -116,14 +116,14 @@ int main() {
116116
}
117117

118118

119-
if(map.find("a") != map.end()) {
120-
std::cout << "Found \"a\"." << std::endl;
119+
if(map.find('d') != map.end()) {
120+
std::cout << "Found 'd'." << std::endl;
121121
}
122122

123-
const std::size_t precalculated_hash = std::hash<std::string>()("a");
123+
const std::size_t precalculated_hash = std::hash<char>()('d');
124124
// If we already know the hash beforehand, we can pass it as argument to speed-up the lookup.
125-
if(map.find("a", precalculated_hash) != map.end()) {
126-
std::cout << "Found \"a\" with hash " << precalculated_hash << "." << std::endl;
125+
if(map.find('d', precalculated_hash) != map.end()) {
126+
std::cout << "Found 'd' with hash " << precalculated_hash << "." << std::endl;
127127
}
128128

129129

0 commit comments

Comments
 (0)