pub trait Bound<T> {
fn lower_bound(&self, x: &T) -> usize;
fn upper_bound(&self, x: &T) -> usize;
}
Required Methods
fn lower_bound(&self, x: &T) -> usize
fn upper_bound(&self, x: &T) -> usize
Implementations on Foreign Types
sourceimpl<T: Ord> Bound<T> for [T]
impl<T: Ord> Bound<T> for [T]
sourcefn lower_bound(&self, x: &T) -> usize
fn lower_bound(&self, x: &T) -> usize
Returns an iterator pointing to the first element in the range [first,last) which does not compare less than val.
use k0i::bounds::Bound;
let vec = vec![1, 2, 4, 6];
assert_eq!(vec.lower_bound(&4), 2);
If the candidate is larger than set’s larget item,returns set’s last index.
use k0i::bounds::Bound;
let vec = vec![1, 2, 4, 6];
assert_eq!(vec.lower_bound(&1000), 3);
sourcefn upper_bound(&self, x: &T) -> usize
fn upper_bound(&self, x: &T) -> usize
Returns an iterator pointing to the first element in the range [first,last) which compares greater than val.
use k0i::bounds::Bound;
let vec = vec![1, 2, 4, 6];
assert_eq!(vec.upper_bound(&4), 3);
If the candidate is larger than set’s larget item,returns set’s last index.
use k0i::bounds::Bound;
let vec = vec![2, 2, 4, 6];
assert_eq!(vec.upper_bound(&1000), 3);