Skip to main content

CellIndex

Struct CellIndex 

Source
pub struct CellIndex { /* private fields */ }
Expand description

The index.

Implementations§

Source§

impl CellIndex

Source

pub fn new(w: f64, arc: f64) -> Self

Build an index with band width w and target sector arc arc, both in hyperbolic units. Measured on 5 461 nodes: 0.5 / 0.5 gives 1 184 cells with a largest cell of 43 (the fixed buckets gave 26 cells and 1 462). Both are stored so cells stay reproducible.

Source

pub fn parameters(&self) -> (f64, f64)

Band width and target arc this index was built with.

Source

pub fn len(&self) -> usize

Live node count.

Source

pub fn is_empty(&self) -> bool

Whether the index holds no nodes.

Source

pub fn cell_count(&self) -> usize

Number of materialised cells — occupancy diagnostics.

Source

pub fn cell_of(&self, point: &HyperbolicPoint) -> CellId

The cell a point belongs to. Comparisons and one division; no transcendental.

Source

pub fn insert(&self, unique_id: &str, point: &HyperbolicPoint)

Register a node. Re-registering an id moves it to its new cell.

Source

pub fn remove(&self, unique_id: &str)

Drop a node.

Source

pub fn knn( &self, query: &HyperbolicPoint, k: usize, ) -> Vec<(String, FixedPoint)>

The k nearest nodes to query, ascending by (distance, unique_id).

Source

pub fn within_radius( &self, centre: &HyperbolicPoint, radius: FixedPoint, ) -> Vec<(String, FixedPoint)>

Every node within radius (hyperbolic) of centre.

Trait Implementations§

Source§

impl Default for CellIndex

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.