stalin_binary_search/lib.rs
1mod vec;
2
3use std::cmp;
4
5pub trait StalinFind<T> {
6 fn len(&self) -> usize;
7 fn is_empty(&self) -> bool;
8
9 fn stalin(&mut self, i: T, l: usize, r: usize) -> Option<usize>
10 where T: cmp::PartialEq + cmp::PartialOrd;
11
12 fn stalin_find(&mut self, i: T) -> Option<usize>
13 where T: cmp::PartialEq + cmp::PartialOrd {
14 if self.is_empty() {
15 None
16 } else {
17 self.stalin(i, 0, self.len() - 1)
18 }
19 }
20}