Skip to main content

KNodeTable

Struct KNodeTable 

Source
pub struct KNodeTable<Id, Info> { /* private fields */ }
Expand description

KNodeTable Implementation This uses a flattened approach whereby buckets are pre-allocated and indexed by their distance from the local Id as a simplification of the allocation based branching approach introduced in the paper.

Implementations§

Source§

impl<Id, Info> KNodeTable<Id, Info>
where Id: DatabaseId + Clone + 'static, Info: Clone + Debug + 'static,

Source

pub fn new(id: Id, bucket_size: usize, hash_size: usize) -> KNodeTable<Id, Info>

Create a new KNodeTable with the provded bucket and hash sizes

Trait Implementations§

Source§

impl<Id, Info> NodeTable<Id, Info> for KNodeTable<Id, Info>
where Id: DatabaseId + Clone + 'static, Info: Clone + Debug + 'static,

Source§

fn create_or_update(&mut self, node: &Entry<Id, Info>) -> bool

Create or update a node in the NodeTable

Source§

fn nearest(&self, id: &Id, range: Range<usize>) -> Vec<Entry<Id, Info>>

Find the nearest nodes to the provided Id in the given range

Source§

fn contains(&self, id: &Id) -> Option<Entry<Id, Info>>

Check if the node NodeTable contains a given node by Id This returns the node object if found

Source§

fn oldest<'a>(&'a self, index: usize) -> Option<Entry<Id, Info>>

Fetch the oldest node in the specified bucket

Source§

fn update_entry<F>(&mut self, id: &Id, f: F) -> bool
where F: Fn(&mut Entry<Id, Info>),

Update an entry by ID

Source§

fn remove_entry(&mut self, id: &Id)

Remove an entry by ID

Source§

fn bucket_info(&self) -> Vec<BucketInfo>

Fetch information from each bucket

Source§

fn buckets(&self) -> usize

Return available number of buckets

Auto Trait Implementations§

§

impl<Id, Info> Freeze for KNodeTable<Id, Info>
where Id: Freeze,

§

impl<Id, Info> RefUnwindSafe for KNodeTable<Id, Info>
where Id: RefUnwindSafe, Info: RefUnwindSafe,

§

impl<Id, Info> Send for KNodeTable<Id, Info>
where Id: Send, Info: Send,

§

impl<Id, Info> Sync for KNodeTable<Id, Info>
where Id: Sync, Info: Sync,

§

impl<Id, Info> Unpin for KNodeTable<Id, Info>
where Id: Unpin, Info: Unpin,

§

impl<Id, Info> UnsafeUnpin for KNodeTable<Id, Info>
where Id: UnsafeUnpin,

§

impl<Id, Info> UnwindSafe for KNodeTable<Id, Info>
where Id: UnwindSafe, Info: 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> 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.