Skip to content

Commit d3ff58b

Browse files
committed
Update readme
1 parent f7d4cde commit d3ff58b

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

README.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
# ConcurrentHashMap C++ Library
1+
# ConcurrentHashMap C++ Library [![Awesome](https://awesome.re/badge.svg)](https://github.com/diffstorm/ConcurrentHashMap)
22

3+
[![CI](https://github.com/diffstorm/ConcurrentHashMap/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/diffstorm/ConcurrentHashMap/actions)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5+
[![C++ Standard](https://img.shields.io/badge/C%2B%2B-17-blue.svg)](https://en.cppreference.com/w/cpp/17)
6+
[![Code Coverage](https://codecov.io/gh/diffstorm/ConcurrentHashMap/branch/main/graph/badge.svg)](https://codecov.io/gh/diffstorm/ConcurrentHashMap)
7+
![GitHub Stars](https://img.shields.io/github/stars/diffstorm/ConcurrentHashMap?style=social)
38

49
A thread-safe hash map implementation in C++ with support for concurrent read and write operations.
510

@@ -10,11 +15,20 @@ A thread-safe hash map implementation in C++ with support for concurrent read an
1015
This is an attempt to create an equivalent of Java's ConcurrentHashMap in C++. It is not a direct equivalent because the underlying concurrency models in Java and C++ are different.
1116

1217

13-
This C++ library and its different versions provides a ConcurrentHashMap class that allows multiple threads to perform read and write operations on a hash map concurrently. It uses std::shared_timed_mutex to provide efficient and safe concurrent access.
18+
This C++ library provides a ConcurrentHashMap class that allows multiple threads to perform read and write operations on a hash map concurrently.
1419

1520

16-
## Usage
21+
## Features
22+
23+
- **Thread-safe** read/write operations
24+
- **Fine-grained locking** with `std::shared_mutex`
25+
- **Modern C++17** API with `std::optional` returns
26+
- **Efficient collision handling** using chaining
27+
- **Comprehensive unit tests** (Google Test)
28+
- **CMake** build system support
29+
1730

31+
## Usage
1832

1933
1. **Include the Library:**
2034
```cpp
@@ -31,8 +45,7 @@ ConcurrentHashMap<std::string, int> concurrentMap;
3145
concurrentMap.insert("one", 1);
3246

3347
// Retrieve the value for a key
34-
int value;
35-
if (concurrentMap.get("one", value)) {
48+
if(auto value = concurrentMap.get("one"))
3649
std::cout << "Value for key 'one': " << value << std::endl;
3750
} else {
3851
std::cout << "Key 'one' not found." << std::endl;
@@ -43,23 +56,42 @@ concurrentMap.remove("one");
4356
```
4457

4558

46-
## Additional Methods:
47-
48-
`print()`: Print the contents of the hash map.
59+
## Advanced Features
4960

61+
Print entire map structure using `print()`.
5062

51-
## Build and Run Example
52-
To compile the example test.cpp, you can use:
63+
Custom hash function support:
5364
```
54-
g++ -std=c++17 test.cpp -o test
65+
struct CustomHash { /* ... */ };
66+
ConcurrentHashMap<KeyType, ValueType, CustomHash> customMap;
5567
```
56-
And run it:
68+
69+
70+
## Build
5771
```
58-
./test
72+
mkdir build && cd build
73+
cmake .. -DCMAKE_BUILD_TYPE=Release
74+
cmake --build . --parallel
5975
```
6076

77+
## Running tests
78+
79+
### After CMake build
80+
cd build && ctest --verbose
81+
82+
### Or directly
83+
./ConcurrentHashMapTest --gtest_color=yes
84+
6185

6286
## License
6387
This project is licensed under the MIT License - see the LICENSE file for details.
6488

65-
Feel free to contribute, report issues, or suggest improvements!
89+
Feel free to contribute, report issues, or suggest improvements!
90+
91+
92+
## Contributing
93+
Contributions welcome! Please:
94+
1. Fork the repository
95+
2. Create your feature branch
96+
3. Submit a Pull Request
97+
4. Ensure all tests pass

0 commit comments

Comments
 (0)