Skip to content

Commit 039ac4a

Browse files
committed
Update documentation.
1 parent 9d220b8 commit 039ac4a

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
11
[![Build Status](https://travis-ci.org/Tessil/array-hash.svg?branch=master)](https://travis-ci.org/Tessil/array-hash) [![Build status](https://ci.appveyor.com/api/projects/status/t50rr5bm6ejf350x/branch/master?svg=true)](https://ci.appveyor.com/project/Tessil/array-hash/branch/master)
22
## A C++ implementation of a fast and memory efficient hash map/set for strings
33

4-
Cache consious hash map for string based on the "Cache-conscious collision resolution in string hash tables." (Askitis Nikolas and Justin Zobel, 2005) paper.
4+
Cache conscious hash map for strings based on the "Cache-conscious collision resolution in string hash tables." (Askitis Nikolas and Justin Zobel, 2005) paper.
5+
6+
Due to its cache friendliness, the structure is well-adapted to store strings long enough to hinder the Small String Optimization (SSO). But even with shorter string, it provides a good balance between speed and memory usage.
57

68
<p align="center">
79
<img src="https://tessil.github.io/images/array_hash.png" width="500px" />
810
</p>
911

1012
The library provides two classes: `tsl::array_map` and `tsl::array_set`.
1113

14+
### Overview
15+
- Header-only library, just include [src/](src/) to your include path and you're ready to go.
16+
- Low memory usage with good performances.
17+
- By default the maximum allowed size for a key is set to 65 535. This can be raised through the `KeySizeT` template parameter.
18+
- By default the maximum size of the map is limited to 4 294 967 296 elements. This can be raised through the `IndexSizeT` template parameter.
19+
20+
21+
Thread-safety and exception guarantees are similar to the STL containers.
22+
23+
### Benchmark
24+
25+
You can find a benchmark of the map on the [`tsl::htrie_map`](https://github.com/Tessil/hat-trie#benchmark) page. But note that the benchmark is not complete as the average size of the key in the dataset can be stored with SSO. A benchmark with longer keys may arrive later.
26+
27+
### Hash function
28+
29+
To avoid dependencies, the default hash function is a simple [FNV-1a](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) hash function. If you can, I recommend to use something like [CityHash](https://github.com/google/cityhash), MurmurHash, [FarmHash](https://github.com/google/farmhash), ... for better performances.
30+
31+
32+
```c++
33+
#include <city.h>
34+
35+
struct str_hash {
36+
std::size_t operator()(const char* key, std::size_t key_size) const {
37+
return CityHash64(key, key_size);
38+
}
39+
};
40+
41+
tsl::array_map<char, int, str_hash> map;
42+
```
43+
1244
### Installation
1345
To use array-hash, just add the [src/](src/) directory to your include path. It's a **header-only** library.
1446
@@ -27,8 +59,10 @@ make
2759
```
2860

2961

62+
3063
### Usage
31-
The API can be found [here](https://tessil.github.io/hopscotch-map/doc/html/).
64+
65+
The API can be found [here](https://tessil.github.io/array-hash/doc_without_string_view/html). If `std::string_view` is available, the API changes slightly and can be found [here](https://tessil.github.io/array-hash/doc/html/).
3266

3367

3468
### Example

0 commit comments

Comments
 (0)