Open a-yasar opened 6 years ago
Hello. No, unfortunately I don't have a C++ implementation.
You can use CLHT in C++, the same way you do in C, e.g., https://github.com/LPD-EPFL/CLHT/blob/master/bmarks/test_mem.c
Plus, you need to add the extern C
def in CLHT, e.g., read https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c#1041880
You should also read the README file: https://github.com/LPD-EPFL/CLHT
The only thing you need to be careful about is that you cannot re-use the same value of a key/value value pair in a concurrent setting. This applies if you put as values memory pointers. As we write in the paper:
the memory allocator of the values must guarantee that the same address cannot appear twice during the lifespan of an operation (see https://infoscience.epfl.ch/record/203822/files/Tech_report_CLHT_BSTTK.pdf for more details)
Thanks a lot! I have another question; at some point can we clean up the hash table (i.e. remove all key-value pairs) and continue to insert new ones?
Hmm, there isn't such an operation. It should be very easy to implement though:
bucket->next
keys[i]
to 0 (similar to the initialization in https://github.com/LPD-EPFL/CLHT/blob/master/src/clht_lb.c#L108)
Is there any c++ implementation of CLHT? If not how can I use it inside of a c++ program?
Thanks in advance!