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§
Sourcefn lower_bound(&self, value: &T) -> usize
fn lower_bound(&self, value: &T) -> usize
x以上となる最小のindexを求める。
Sourcefn upper_bound(&self, value: &T) -> usize
fn upper_bound(&self, value: &T) -> usize
xを超える最小のindexを求める。
Provided Methods§
Sourcefn equal_range(&self, value: &T) -> (usize, usize)
fn equal_range(&self, value: &T) -> (usize, usize)
lower_bound, upper_boundの組を求める。
Implementations on Foreign Types§
Source§impl<T: Ord> BinarySearch<T> for [T]
impl<T: Ord> BinarySearch<T> for [T]
Source§fn lower_bound(&self, value: &T) -> usize
fn lower_bound(&self, value: &T) -> usize
x以上となる最小のindexを求める。
Time complexity $O(\log n)$
Source§fn upper_bound(&self, value: &T) -> usize
fn upper_bound(&self, value: &T) -> usize
xを超える最小のindexを求める。
Time complexity $O(\log n)$