pub struct Heap<V>{
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>
impl<V> Heap<V>
Sourcepub fn find_min(&self) -> Block<HeapElement<V>>
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>
withpos = DUMMY
=> if the heap is empty.
Sourcepub fn insert(&mut self, key: K, value: V) -> (PositionType, K)
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.
Sourcepub fn delete(&mut self, pos: PositionType, timestamp: K)
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.
Sourcepub fn extract_min(&mut self)
pub fn extract_min(&mut self)
Find and delete the minimum element from the heap.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more