pub trait TryAddressableHeap<K, V> {
type Handle: Copy + Eq;
type InsertError;
// Required methods
fn try_insert(
&mut self,
key: K,
value: V,
) -> Result<Self::Handle, Self::InsertError>;
fn peek(&self) -> Option<(Self::Handle, &K, &V)>;
fn pop(&mut self) -> Option<(K, V)>;
fn key(&self, handle: Self::Handle) -> Result<&K, InvalidHandle>;
fn value(&self, handle: Self::Handle) -> Result<&V, InvalidHandle>;
fn value_mut(
&mut self,
handle: Self::Handle,
) -> Result<&mut V, InvalidHandle>;
fn delete(&mut self, handle: Self::Handle) -> Result<(K, V), InvalidHandle>;
fn len(&self) -> usize;
fn clear(&mut self);
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A min-oriented heap whose entries are addressed by stable handles and whose insertion can fail because of algorithm-specific key restrictions.
Complements AddressableHeap the same way TryHeap complements
Heap.
Required Associated Types§
Sourcetype InsertError
type InsertError
Error returned when an entry cannot be inserted.
Required Methods§
Sourcefn try_insert(
&mut self,
key: K,
value: V,
) -> Result<Self::Handle, Self::InsertError>
fn try_insert( &mut self, key: K, value: V, ) -> Result<Self::Handle, Self::InsertError>
Attempts to insert an entry and returns its handle.
§Errors
Returns an error if key violates this heap’s key restrictions.
Sourcefn peek(&self) -> Option<(Self::Handle, &K, &V)>
fn peek(&self) -> Option<(Self::Handle, &K, &V)>
Returns the handle, key, and value of a minimum entry, if present.
Sourcefn key(&self, handle: Self::Handle) -> Result<&K, InvalidHandle>
fn key(&self, handle: Self::Handle) -> Result<&K, InvalidHandle>
Returns the key identified by handle.
§Errors
Returns an error if handle is stale or belongs to another heap.
Sourcefn value(&self, handle: Self::Handle) -> Result<&V, InvalidHandle>
fn value(&self, handle: Self::Handle) -> Result<&V, InvalidHandle>
Returns the value identified by handle.
§Errors
Returns an error if handle is stale or belongs to another heap.
Sourcefn value_mut(&mut self, handle: Self::Handle) -> Result<&mut V, InvalidHandle>
fn value_mut(&mut self, handle: Self::Handle) -> Result<&mut V, InvalidHandle>
Returns mutable access to the value identified by handle.
§Errors
Returns an error if handle is stale or belongs to another heap.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".