pub struct Buckets<T: Bucketable> { /* private fields */ }
Expand description
This data structure implements the bucket system described in BEP0005 (more or less).
Implementations§
Source§impl<T: Bucketable> Buckets<T>
impl<T: Bucketable> Buckets<T>
pub fn new(our_id: Id, k: usize) -> Buckets<T>
pub fn add(&mut self, item: T, chump_list: Option<&mut Vec<T>>)
pub fn clear(&mut self)
pub fn contains(&self, id: &Id) -> bool
pub fn count(&self) -> usize
pub fn count_buckets(&self) -> usize
pub fn get_mut(&mut self, id: &Id) -> Option<&mut T>
Sourcepub fn get_nearest_nodes(&self, id: &Id, exclude: Option<&Id>) -> Vec<&T>
pub fn get_nearest_nodes(&self, id: &Id, exclude: Option<&Id>) -> Vec<&T>
Get the k
nearest nodes/items stored in the buckets
The returned vector is sorted by distance, from nearest to farthest.
pub fn retain<F>(&mut self, f: F)
pub fn remove(&mut self, id: &Id) -> Option<T>
pub fn set_id(&mut self, new_id: Id)
pub fn values(&self) -> Vec<&T>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Buckets<T>
impl<T> RefUnwindSafe for Buckets<T>where
T: RefUnwindSafe,
impl<T> Send for Buckets<T>where
T: Send,
impl<T> Sync for Buckets<T>where
T: Sync,
impl<T> Unpin for Buckets<T>where
T: Unpin,
impl<T> UnwindSafe for Buckets<T>where
T: UnwindSafe,
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