Struct Static2DTree

Source
pub struct Static2DTree<T, U, V>
where T: Ord, U: Ord,
{ /* private fields */ }

Implementations§

Source§

impl<T, U, V> Static2DTree<T, U, V>
where T: Ord, U: Ord,

Source

pub fn new<I>(data: I) -> Self
where I: IntoIterator<Item = (T, U, V)>,

Examples found in repository?
crates/aizu_online_judge/src/dsl/dsl_2_c.rs (line 10)
6pub fn dsl_2_c(reader: impl Read, mut writer: impl Write) {
7    let s = read_all_unchecked(reader);
8    let mut scanner = Scanner::new(&s);
9    scan!(scanner, n, xy: [(i64, i64)]);
10    let tree = Static2DTree::new(xy.take(n).enumerate().map(|(i, (x, y))| (x, y, i)));
11    scan!(scanner, q, query: [(i64, i64, i64, i64)]);
12    for (sx, tx, sy, ty) in query.take(q) {
13        let mut v = tree.range(sx..tx + 1, sy..ty + 1);
14        v.sort();
15        for v in v {
16            writeln!(writer, "{}", v).ok();
17        }
18        writeln!(writer).ok();
19    }
20}
Source

pub fn range(&self, range1: Range<T>, range2: Range<U>) -> Vec<&V>

Examples found in repository?
crates/aizu_online_judge/src/dsl/dsl_2_c.rs (line 13)
6pub fn dsl_2_c(reader: impl Read, mut writer: impl Write) {
7    let s = read_all_unchecked(reader);
8    let mut scanner = Scanner::new(&s);
9    scan!(scanner, n, xy: [(i64, i64)]);
10    let tree = Static2DTree::new(xy.take(n).enumerate().map(|(i, (x, y))| (x, y, i)));
11    scan!(scanner, q, query: [(i64, i64, i64, i64)]);
12    for (sx, tx, sy, ty) in query.take(q) {
13        let mut v = tree.range(sx..tx + 1, sy..ty + 1);
14        v.sort();
15        for v in v {
16            writeln!(writer, "{}", v).ok();
17        }
18        writeln!(writer).ok();
19    }
20}

Auto Trait Implementations§

§

impl<T, U, V> Freeze for Static2DTree<T, U, V>

§

impl<T, U, V> RefUnwindSafe for Static2DTree<T, U, V>

§

impl<T, U, V> Send for Static2DTree<T, U, V>
where T: Send, U: Send, V: Send,

§

impl<T, U, V> Sync for Static2DTree<T, U, V>
where T: Sync, U: Sync, V: Sync,

§

impl<T, U, V> Unpin for Static2DTree<T, U, V>
where T: Unpin, U: Unpin, V: Unpin,

§

impl<T, U, V> UnwindSafe for Static2DTree<T, U, V>
where T: UnwindSafe, U: UnwindSafe, V: 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.