Struct Heap

Source
pub struct Heap<V>
where V: Cmov + Pod,
{ pub data: CircuitORAM<HeapElement<V>>, pub metadata: HeapTree<Block<HeapElement<V>>>, pub rng: ThreadRng, pub max_size: usize, pub timestamp: K, }
Expand description

An oblivious heap. Elements are stored in an ORAM, along with information about the location of the minimum element in each subtree.

§Invariants

  • metadata stores the minimum element in each subtree.
  • Heap elements are stored in a non-recursive ORAM.
  • After insertion, the oram key (timestamp) and path for an element do not change.

Fields§

§data: CircuitORAM<HeapElement<V>>

The heap elements.

§metadata: HeapTree<Block<HeapElement<V>>>

The metadata tree used for storing the element with minimum key in the subtree.

§rng: ThreadRng

Thread local rng.

§max_size: usize

maximum size of the heap.

§timestamp: K

timestamp: usize,

Implementations§

Source§

impl<V> Heap<V>
where V: Cmov + Pod + Debug,

Source

pub fn new(n: usize) -> Self

Creates a Heap with maximum size of n elements.

Source

pub fn find_min(&self) -> Block<HeapElement<V>>

Finds the minimum element in the heap.

§Returns
  • The minimum element in the heap. => if the heap is non-empty.
  • A HeapElement<V> with pos = DUMMY => if the heap is empty.
Source

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

Inserts a new element value with priority key into the heap.

§Returns
  • the position and timestamp of the inserted element.
Source

pub fn delete(&mut self, pos: PositionType, timestamp: K)

Deletes an element from the heap given it’s timestamp and path.

§Behavior
  • If the element is not in the heap, nothing happens.
Source

pub fn extract_min(&mut self)

Find and delete the minimum element from the heap.

Trait Implementations§

Source§

impl<V> Debug for Heap<V>
where V: Cmov + Pod + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<V> Freeze for Heap<V>

§

impl<V> !RefUnwindSafe for Heap<V>

§

impl<V> !Send for Heap<V>

§

impl<V> !Sync for Heap<V>

§

impl<V> Unpin for Heap<V>
where V: Unpin,

§

impl<V> !UnwindSafe for Heap<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