Struct UnsortedMap

Source
pub struct UnsortedMap<K, V>
where K: OHash + Default + Debug, V: Cmov + Pod + Default + Debug,
{ /* private fields */ }
Expand description

An unsorted map that is oblivious to the access pattern. The map uses cuckoo hashing with size-2 buckets, two tables and a deamortization queue. INSERTION_QUEUE_MAX_SIZE is the maximum size of the deamortization queue. DEAMORTIZED_INSERTIONS is the number of deamortized insertions to perform per insert call.

§Invariants

  • A key appears at most once in a valid element in between the two tables and the insertion queue.
  • The two tables have the same capacity.
  • The two tables have a different hash functions (different keys on the keyed hash function).

Implementations§

Source§

impl<K, V> UnsortedMap<K, V>
where K: OHash + Default + Debug, V: Cmov + Pod + Default + Debug,

Source

pub fn new(capacity: usize) -> Self

Creates a new UnsortedMap with the given capacity n.

Source

pub fn get(&mut self, key: K, ret: &mut V) -> bool

Tries to get a value from the map.

§Returns
  • true if the key was found
  • false if the key wasn’t found
§Postconditions
  • If the key was found, the value is written to ret
  • If the key wasn’t found, ret is not modified
Source

pub fn deamortize_insertion_queue(&mut self)

Deamortizes the insertion queue by trying to insert elements into the tables.

Source

pub fn insert(&mut self, key: K, value: V)

Inserts an elementn into the map. If the insertion doesn’t finish, the removed element is inserted into the insertion queue.

§Preconditions
  • The key is not in the map already.
Source

pub fn write(&mut self, key: K, value: V)

Updates a value that is already in the map.

§Preconditions
  • The key is in the map.
§Returns
  • true if the value was updated

Trait Implementations§

Source§

impl<K, V> Debug for UnsortedMap<K, V>
where K: OHash + Default + Debug + Debug, V: Cmov + Pod + Default + Debug + Debug,

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 UnsortedMap<K, V>
where K: Freeze, V: Freeze,

§

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

§

impl<K, V> !Send for UnsortedMap<K, V>

§

impl<K, V> !Sync for UnsortedMap<K, V>

§

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

§

impl<K, V> !UnwindSafe for UnsortedMap<K, V>

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> 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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V