[][src]Struct quadtree_rs::entry::Entry

pub struct Entry<U, V> where
    U: PrimInt + Default
{ /* fields omitted */ }

A region/value association in the Quadtree.

Entry is used both for read-only access into a quadtree (i.e. .get()) and as the return type for mutating operations (i.e. .delete(), which returns iter::IntoIter<U, V>, which is iterable over former Entry<U, V> entries).

use quadtree_rs::{
  area::AreaBuilder,
  Quadtree,
};

let mut qt = Quadtree::<u32, f64>::new(4);
let region_a = AreaBuilder::default()
    .anchor((1, 1).into())
    .dimensions((3, 2))
    .build().unwrap();

qt.insert(region_a, 4.56_f64);

// Calling Quadtree::delete() on a region in the tree clears that region of the tree and returns the region/value associations which were deleted.

let region_b = AreaBuilder::default()
    .anchor((2, 1).into())
    .build().unwrap();

// The iterator contains Entry<U, V> structs.
let mut returned_entries = qt.delete(region_b);

let entry = returned_entries.next().unwrap();

assert_eq!(entry.anchor().x(), 1);
assert_eq!(entry.anchor().y(), 1);
assert_eq!(entry.width(), 3);
assert_eq!(entry.height(), 2);

assert_eq!(entry.value_ref(), &4.56);

Methods

impl<U, V> Entry<U, V> where
    U: PrimInt + Default
[src]

pub fn area(&self) -> Area<U>[src]

The returned region.

pub fn anchor(&self) -> Point<U>[src]

The top-left coordinate of the returned region.

pub fn width(&self) -> U[src]

The width of the returned region.

pub fn height(&self) -> U[src]

The height of the returned region.

pub fn value_mut(&mut self) -> &mut V[src]

A mutable accessor to the returned value.

pub fn value_ref(&self) -> &V[src]

A reference to the returned value.

Trait Implementations

impl<U: PartialEq, V: PartialEq> PartialEq<Entry<U, V>> for Entry<U, V> where
    U: PrimInt + Default
[src]

impl<U: Eq, V: Eq> Eq for Entry<U, V> where
    U: PrimInt + Default
[src]

impl<U: Debug, V: Debug> Debug for Entry<U, V> where
    U: PrimInt + Default
[src]

Auto Trait Implementations

impl<U, V> Send for Entry<U, V> where
    U: Send,
    V: Send

impl<U, V> Sync for Entry<U, V> where
    U: Sync,
    V: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.