|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Transposition-table container built on top of Aleph hash maps. More...
#include <Transposition_Table.H>
Public Types | |
| using | Key_Type = Key |
| using | Entry_Type = Entry |
| using | Map_Type = SearchStorageMap< Key, Entry, HashMapTable, Cmp > |
| using | Replace_Policy = ReplacePolicy |
Public Member Functions | |
| Transposition_Table ()=default | |
| Build an empty table with the default replacement policy. | |
| Transposition_Table (ReplacePolicy replace) | |
| Build a table with a custom replacement policy instance. | |
| void | clear () noexcept |
| Remove all stored entries. | |
| void | reset_stats () noexcept |
| Reset only the accumulated storage statistics. | |
| size_t | size () const noexcept |
| Number of currently stored entries. | |
| bool | is_empty () const noexcept |
Return true if the table contains no entries. | |
| const TranspositionStats & | stats () const noexcept |
| Read-only access to accumulated storage statistics. | |
| Entry * | probe (const Key &key) |
| Probe one key and return the stored entry if present. | |
| Entry * | probe (Key &&key) |
| Probe one key using move semantics. | |
| TranspositionStoreStatus | store (const Key &key, const Entry &entry) |
Store a candidate entry for key. | |
| TranspositionStoreStatus | store (Key &&key, Entry entry) |
Store a candidate entry for key using move semantics. | |
Static Public Attributes | |
| static constexpr bool | enabled = true |
| Compile-time marker for search adapters. | |
Private Member Functions | |
| template<typename KeyLike > | |
| Entry * | probe_impl (KeyLike &&key) |
| template<typename KeyLike , typename EntryLike > | |
| TranspositionStoreStatus | store_impl (KeyLike &&key, EntryLike &&entry) |
Private Attributes | |
| Map_Type | table_ |
| ReplacePolicy | replace_ = {} |
| TranspositionStats | stats_ |
Transposition-table container built on top of Aleph hash maps.
Thread-safety: all member functions require external synchronization. The table stores entries in-place and returns mutable pointers when probing; as such, callers must ensure only one thread manipulates the table at a time.
| Key | Stable cache key type. |
| Entry | Cached value associated with Key. |
| HashMapTable | Aleph hash-table backend, MapOLhash by default. |
| Cmp | Equality comparator for keys. |
| ReplacePolicy | Policy deciding whether a new entry overwrites an existing entry for the same key. |
Definition at line 169 of file Transposition_Table.H.
| using Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::Entry_Type = Entry |
Definition at line 175 of file Transposition_Table.H.
| using Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::Key_Type = Key |
Definition at line 174 of file Transposition_Table.H.
| using Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::Map_Type = SearchStorageMap<Key, Entry, HashMapTable, Cmp> |
Definition at line 176 of file Transposition_Table.H.
| using Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::Replace_Policy = ReplacePolicy |
Definition at line 177 of file Transposition_Table.H.
|
default |
Build an empty table with the default replacement policy.
|
inlineexplicit |
Build a table with a custom replacement policy instance.
| replace | Replacement policy functor. |
Definition at line 188 of file Transposition_Table.H.
|
inlinenoexcept |
Remove all stored entries.
Definition at line 196 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::table_.
|
inlinenoexcept |
Return true if the table contains no entries.
Definition at line 220 of file Transposition_Table.H.
References Aleph::HashMap< Key, Data, HashMapTable, Cmp >::is_empty(), and Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::table_.
|
inline |
Probe one key and return the stored entry if present.
| key | Cache key. |
nullptr on miss. Definition at line 238 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::probe_impl().
|
inline |
Probe one key using move semantics.
| key | Cache key (consumed). |
nullptr on miss. Definition at line 248 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::probe_impl().
|
inlineprivate |
Definition at line 282 of file Transposition_Table.H.
References Aleph::TranspositionStats::hits, Aleph::TranspositionStats::misses, Aleph::TranspositionStats::probes, Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::stats_, and Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::table_.
Referenced by Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::probe(), and Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::probe().
|
inlinenoexcept |
Reset only the accumulated storage statistics.
Definition at line 204 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::stats_.
|
inlinenoexcept |
Number of currently stored entries.
Definition at line 212 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::table_.
|
inlinenoexcept |
Read-only access to accumulated storage statistics.
Definition at line 228 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::stats_.
|
inline |
Store a candidate entry for key.
If the key is absent, the entry is inserted. Otherwise the configured replacement policy decides whether the current entry is overwritten.
| key | Cache key. |
| entry | Candidate entry to store. |
Definition at line 264 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::store_impl().
|
inline |
Store a candidate entry for key using move semantics.
| key | Cache key (consumed). |
| entry | Entry moved into storage. |
Definition at line 275 of file Transposition_Table.H.
References Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::store_impl().
|
inlineprivate |
Definition at line 298 of file Transposition_Table.H.
References Aleph::divide_and_conquer_partition_dp(), Aleph::Inserted, Aleph::Rejected, Aleph::TranspositionStats::rejected_updates, Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::replace_, Aleph::Replaced, Aleph::TranspositionStats::replacements, Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::stats_, Aleph::TranspositionStats::stores, and Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::table_.
Referenced by Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::store(), and Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::store().
|
staticconstexpr |
Compile-time marker for search adapters.
Definition at line 172 of file Transposition_Table.H.
|
private |
Definition at line 320 of file Transposition_Table.H.
Referenced by Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::store_impl().
|
private |
Definition at line 321 of file Transposition_Table.H.
Referenced by Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::probe_impl(), Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::reset_stats(), Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::stats(), and Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::store_impl().
|
private |
Definition at line 319 of file Transposition_Table.H.
Referenced by Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::clear(), Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::is_empty(), Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::probe_impl(), Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::size(), and Aleph::Transposition_Table< Key, Entry, HashMapTable, Cmp, ReplacePolicy >::store_impl().