pub trait TwoBucket:
Debug
+ Default
+ Sync {
// Required methods
fn get(&self, hash: HashKind) -> Option<Entry>;
fn contains(&self, hash: HashKind) -> bool;
fn store(&self, general_entry: Entry);
fn replace(&self, priority_entry: Entry, age: u8);
fn swap_replace(&self, priority_entry: Entry, age: u8);
fn replace_by<F>(&self, entry: Entry, age: u8, should_replace: F)
where F: FnOnce(&Entry, u8, &Entry, u8) -> bool;
fn swap_replace_by<F>(&self, entry: Entry, age: u8, should_replace: F)
where F: FnOnce(&Entry, u8, &Entry, u8) -> bool;
// Provided method
fn len() -> usize { ... }
}
Expand description
Transposition Table Bucket that holds 2 entries, consisting of a priority slot and a general slot.
Required Methods§
Sourcefn get(&self, hash: HashKind) -> Option<Entry>
fn get(&self, hash: HashKind) -> Option<Entry>
Returns an entry if its corresponding hash exists in this bucket. If no entry’s hash matches the given hash, returns None.
Sourcefn contains(&self, hash: HashKind) -> bool
fn contains(&self, hash: HashKind) -> bool
Returns true if this bucket has any entry which contains the given hash.
Sourcefn store(&self, general_entry: Entry)
fn store(&self, general_entry: Entry)
Unconditionally store the entry in the general slot, without updating age.
Sourcefn replace(&self, priority_entry: Entry, age: u8)
fn replace(&self, priority_entry: Entry, age: u8)
Unconditionally place the entry in the priority slot and update age.
Sourcefn swap_replace(&self, priority_entry: Entry, age: u8)
fn swap_replace(&self, priority_entry: Entry, age: u8)
Move the existing priority entry to the general slot, then place the new priority entry into the priority slot and update age.
Sourcefn replace_by<F>(&self, entry: Entry, age: u8, should_replace: F)
fn replace_by<F>(&self, entry: Entry, age: u8, should_replace: F)
Replaces the priority
slot if should_replace
returns true,
otherwise the general
slot is replaced.
§Example:
if should_replace { priority := entry } else { general := entry }
FnOnce signature:
should_replace(&new_entry, new_age, &existing_priority_entry, existing_age) -> bool
Sourcefn swap_replace_by<F>(&self, entry: Entry, age: u8, should_replace: F)
fn swap_replace_by<F>(&self, entry: Entry, age: u8, should_replace: F)
If should_replace returns true, then swap_replace with the given entry.
Example:
if should_replace { general := priority priority := entry } else { general := entry }
FnOnce signature:
should_replace(&new_entry, new_age, &existing_priority_entry, existing_age) -> bool
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.