You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file is part of the Sanmill project, which is a board game engine. It includes the implementation of a thread-safe hash table using a template for the key-value pair. The hash table is divided into buckets, and each bucket is represented as a singly linked list of nodes.
The HashNode class template is defined with two template parameters: K for the key type and V for the value type. It represents a node in the hash table that holds a key-value pair. It also contains a pointer to the next node in the same bucket when hash bucket is not disabled.
The HashBucket class template also has two template parameters, K for the key type and V for the value type. It represents a bucket in the hash table, which is a singly linked list of nodes. The bucket uses a shared mutex to enable multiple concurrent reads, while an exclusive lock is used for single writes.
The HashBucket class has several functions:
find: Searches for an entry in the bucket matching the key. If found, it copies the value into the output parameter and returns true; otherwise, it returns false.
insert: Inserts a new node with the specified key-value pair into the bucket. If the key already exists, the value is updated.
erase: Removes an entry from the bucket if it is found.
clear: Clears the bucket by deleting all nodes.
All of the functions in the HashBucket class use the appropriate lock to ensure thread safety.
This is a C++ header file for the HashMap class, which is part of the Sanmill project. The header file defines a concurrent, thread-safe hash map implementation. The hash map is a data structure that can store key-value pairs, allowing efficient insertion, deletion, and searching operations. In this implementation, each bucket in the hash map is a singly linked list with a dummy head node. The HashMap class is defined within the CTSL (Concurrent Thread Safe Library) namespace.
The class has the following main methods:
find: Finds an entry in the hash map matching the given key. If found, the corresponding value is returned; otherwise, the function returns false.
insert: Inserts a key-value pair into the hash map. If the key already exists, the value is updated; otherwise, a new node is inserted in the bucket.
erase: Removes an entry from the bucket if found.
clear: Removes all entries from the hash map.
resize: Resizes the hash map if the new size is greater than a specified threshold.
dump: Dumps the hash map to a file.
load: Loads the hash map from a file.
merge: Merges the current hash map with another hash map.
stat: Provides statistics about the hash map, such as the number of entries.
The class also has some private members, including the hash table (either an array of HashNode or HashBucket objects), the hash function, the hash size, and a mutex for thread safety (if not disabled).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This file is part of the Sanmill project, which is a board game engine. It includes the implementation of a thread-safe hash table using a template for the key-value pair. The hash table is divided into buckets, and each bucket is represented as a singly linked list of nodes.
The HashNode class template is defined with two template parameters: K for the key type and V for the value type. It represents a node in the hash table that holds a key-value pair. It also contains a pointer to the next node in the same bucket when hash bucket is not disabled.
The HashBucket class template also has two template parameters, K for the key type and V for the value type. It represents a bucket in the hash table, which is a singly linked list of nodes. The bucket uses a shared mutex to enable multiple concurrent reads, while an exclusive lock is used for single writes.
The HashBucket class has several functions:
find: Searches for an entry in the bucket matching the key. If found, it copies the value into the output parameter and returns true; otherwise, it returns false.
insert: Inserts a new node with the specified key-value pair into the bucket. If the key already exists, the value is updated.
erase: Removes an entry from the bucket if it is found.
clear: Clears the bucket by deleting all nodes.
All of the functions in the HashBucket class use the appropriate lock to ensure thread safety.
This is a C++ header file for the HashMap class, which is part of the Sanmill project. The header file defines a concurrent, thread-safe hash map implementation. The hash map is a data structure that can store key-value pairs, allowing efficient insertion, deletion, and searching operations. In this implementation, each bucket in the hash map is a singly linked list with a dummy head node. The HashMap class is defined within the CTSL (Concurrent Thread Safe Library) namespace.
The class has the following main methods:
find: Finds an entry in the hash map matching the given key. If found, the corresponding value is returned; otherwise, the function returns false.
insert: Inserts a key-value pair into the hash map. If the key already exists, the value is updated; otherwise, a new node is inserted in the bucket.
erase: Removes an entry from the bucket if found.
clear: Removes all entries from the hash map.
resize: Resizes the hash map if the new size is greater than a specified threshold.
dump: Dumps the hash map to a file.
load: Loads the hash map from a file.
merge: Merges the current hash map with another hash map.
stat: Provides statistics about the hash map, such as the number of entries.
The class also has some private members, including the hash table (either an array of HashNode or HashBucket objects), the hash function, the hash size, and a mutex for thread safety (if not disabled).
Beta Was this translation helpful? Give feedback.
All reactions