Skip to main content

MapTable

Struct MapTable 

Source
pub struct MapTable<K, M, S> { /* private fields */ }
Expand description

A transposition table backed by a hash map, holding up to a fixed number of entries.

Unlike SlotTable, keys never share a slot, so an entry stays until MapTable::clear. Once the map is full, entries for new keys are dropped, while known keys are still updated. Keys need Hash, and memory grows with the entries stored.

Available with the hashbrown feature.

§Examples

use game_tree_search::{MapTable, Table};

let mut table = MapTable::<u64, u8, i32>::new(1);
assert!(table.is_empty());
assert_eq!(table.capacity(), 1);

Implementations§

Source§

impl<K: Eq + Hash, M: Clone, S: Clone> MapTable<K, M, S>

Source

pub fn new(capacity: usize) -> Self

An empty table that keeps up to capacity entries.

Source

pub const fn capacity(&self) -> usize

The most entries the table keeps.

Source

pub fn len(&self) -> usize

The number of entries stored.

Source

pub fn is_empty(&self) -> bool

Whether the table holds no entries.

Source

pub fn clear(&mut self)

Removes every entry, for example before searching a different game.

Trait Implementations§

Source§

impl<K: Clone, M: Clone, S: Clone> Clone for MapTable<K, M, S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug, M: Debug, S: Debug> Debug for MapTable<K, M, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Eq + Hash, M: Clone, S: Clone> Table<K, M, S> for MapTable<K, M, S>

Source§

fn probe(&mut self, key: &K) -> Option<Entry<M, S>>

The entry stored for key, if any.
Source§

fn store(&mut self, key: K, entry: Entry<M, S>)

Stores entry for key; the table may keep or drop it, or evict another entry.

Auto Trait Implementations§

§

impl<K, M, S> Forget for MapTable<K, M, S>

§

impl<K, M, S> Freeze for MapTable<K, M, S>
where HashMap<K, Entry<M, S>>: Freeze,

§

impl<K, M, S> Move for MapTable<K, M, S>

§

impl<K, M, S> RefUnwindSafe for MapTable<K, M, S>
where HashMap<K, Entry<M, S>>: RefUnwindSafe,

§

impl<K, M, S> Send for MapTable<K, M, S>
where HashMap<K, Entry<M, S>>: Send,

§

impl<K, M, S> Sync for MapTable<K, M, S>
where HashMap<K, Entry<M, S>>: Sync,

§

impl<K, M, S> Unpin for MapTable<K, M, S>
where HashMap<K, Entry<M, S>>: Unpin,

§

impl<K, M, S> UnsafeUnpin for MapTable<K, M, S>
where HashMap<K, Entry<M, S>>: UnsafeUnpin,

§

impl<K, M, S> UnwindSafe for MapTable<K, M, S>
where HashMap<K, Entry<M, S>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.