Trait BinarySearch

Source
pub trait BinarySearch<T> {
    // Required methods
    fn lower_bound(&self, value: &T) -> usize;
    fn upper_bound(&self, value: &T) -> usize;

    // Provided method
    fn equal_range(&self, value: &T) -> (usize, usize) { ... }
}
Expand description

Required Methods§

Source

fn lower_bound(&self, value: &T) -> usize

x以上となる最小のindexを求める。

Source

fn upper_bound(&self, value: &T) -> usize

xを超える最小のindexを求める。

Provided Methods§

Source

fn equal_range(&self, value: &T) -> (usize, usize)

lower_bound, upper_boundの組を求める。

Implementations on Foreign Types§

Source§

impl<T: Ord> BinarySearch<T> for [T]

Source§

fn lower_bound(&self, value: &T) -> usize

x以上となる最小のindexを求める。

Time complexity $O(\log n)$

Source§

fn upper_bound(&self, value: &T) -> usize

xを超える最小のindexを求める。

Time complexity $O(\log n)$

Implementors§