Struct SyncHashMapB

Source
pub struct SyncHashMapB<K: Eq + Hash, V> { /* private fields */ }

Implementations§

Source§

impl<K: Eq + Hash, V> SyncHashMapB<K, V>

Source

pub fn new(bucket_count: Option<usize>) -> Self

Source

pub fn insert(&self, k: K, v: V) -> Option<V>

use fast_able::{SyncHashMapB};

let mut map = SyncHashMapB::new(None);
map.insert(1, "a");
map.insert(2, "b");
assert_eq!(*map.get(&1).unwrap(), "a");
assert_eq!(map.get(&2).is_none(), false);
assert_eq!(map.get(&3).is_none(), true);
Source

pub fn insert_mut(&mut self, k: K, v: V) -> Option<V>

Source

pub fn remove(&self, k: &K) -> Option<V>

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn clear(&self)

Source

pub fn get(&self, k: &K) -> Option<&V>

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

Since reading a map is unlocked, it is very fast

test bench_sync_hash_map_read … bench: 8 ns/iter (+/- 0)

§Examples
use fast_able::{SyncHashMapB};

let mut map = SyncHashMapB::new(None);
map.insert_mut(1, "a");
assert_eq!(*map.get(&1).unwrap(), "a");
assert_eq!(map.get(&2).is_none(), true);
Source

pub fn get_mut(&self, k: &K) -> Option<SyncMapRefMut<'_, V>>

Trait Implementations§

Source§

impl<K: Clone + Eq + Hash, V: Clone> Clone for SyncHashMapB<K, V>

Source§

fn clone(&self) -> SyncHashMapB<K, V>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<K: Debug + Eq + Hash, V: Debug> Debug for SyncHashMapB<K, V>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for SyncHashMapB<K, V>

§

impl<K, V> !RefUnwindSafe for SyncHashMapB<K, V>

§

impl<K, V> Send for SyncHashMapB<K, V>

§

impl<K, V> Sync for SyncHashMapB<K, V>

§

impl<K, V> Unpin for SyncHashMapB<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for SyncHashMapB<K, V>
where K: UnwindSafe, V: 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.