line break
This commit is contained in:
@@ -114,33 +114,33 @@ if (itr != my_data.end()) {
|
|||||||
|
|
||||||
- Using the default std::string hash function.
|
- Using the default std::string hash function.
|
||||||
|
|
||||||
– With no specified initial table size. (map a std::string type key to a class Foo type value)
|
- With no specified initial table size. (map a std::string type key to a class Foo type value)
|
||||||
```cpp
|
```cpp
|
||||||
std::unordered_map<std::string,Foo> m;
|
std::unordered_map<std::string,Foo> m;
|
||||||
```
|
```
|
||||||
|
|
||||||
– Optionally specifying initial (minimum) table size.
|
- Optionally specifying initial (minimum) table size.
|
||||||
```cpp
|
```cpp
|
||||||
std::unordered_map<std::string,Foo> m(1000);
|
std::unordered_map<std::string,Foo> m(1000);
|
||||||
```
|
```
|
||||||
- Using a home-made std::string hash function. Note: We are required to specify the initial table size.
|
- Using a home-made std::string hash function. Note: We are required to specify the initial table size.
|
||||||
– Manually specifying the hash function type.
|
- Manually specifying the hash function type.
|
||||||
```cpp
|
```cpp
|
||||||
std::unordered_map<std::string,Foo,std::function<unsigned int(std::string)> > m(1000, MyHashFunction);
|
std::unordered_map<std::string,Foo,std::function<unsigned int(std::string)> > m(1000, MyHashFunction);
|
||||||
```
|
```
|
||||||
|
|
||||||
– Using the decltype specifier to get the “declared type of an entity”.
|
- Using the decltype specifier to get the “declared type of an entity”.
|
||||||
```cpp
|
```cpp
|
||||||
std::unordered_map<std::string,Foo,decltype(&MyHashFunction)> m(1000, MyHashFunction);
|
std::unordered_map<std::string,Foo,decltype(&MyHashFunction)> m(1000, MyHashFunction);
|
||||||
```
|
```
|
||||||
- Using a home-made std::string hash functor or function object.
|
- Using a home-made std::string hash functor or function object.
|
||||||
|
|
||||||
– With no specified initial table size.
|
- With no specified initial table size.
|
||||||
```cpp
|
```cpp
|
||||||
std::unordered_map<std::string,Foo,MyHashFunctor> m;
|
std::unordered_map<std::string,Foo,MyHashFunctor> m;
|
||||||
```
|
```
|
||||||
|
|
||||||
– Optionally specifying initial (minimum) table size.
|
- Optionally specifying initial (minimum) table size.
|
||||||
```cpp
|
```cpp
|
||||||
std::unordered_map<std::string,Foo,MyHashFunctor> m(1000);
|
std::unordered_map<std::string,Foo,MyHashFunctor> m(1000);
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user