Remove anchor collections

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-12-09 16:38:46 +01:00
parent 67686dd1c2
commit 65711b2256
18 changed files with 659 additions and 322 deletions

View file

@ -1,8 +1,7 @@
mod cursor;
use arrayvec::ArrayVec;
pub use cursor::Cursor;
pub use cursor::FilterCursor;
pub use cursor::{Cursor, FilterCursor, Iter};
use std::marker::PhantomData;
use std::{cmp::Ordering, fmt, iter::FromIterator, sync::Arc};
@ -156,6 +155,10 @@ impl<T: Item> SumTree<T> {
items
}
pub fn iter(&self) -> Iter<T> {
Iter::new(self)
}
pub fn cursor<'a, S>(&'a self) -> Cursor<T, S>
where
S: Dimension<'a, T::Summary>,
@ -722,6 +725,10 @@ mod tests {
};
assert_eq!(tree.items(&()), reference_items);
assert_eq!(
tree.iter().collect::<Vec<_>>(),
tree.cursor::<()>().collect::<Vec<_>>()
);
let mut filter_cursor =
tree.filter::<_, Count>(|summary| summary.contains_even, &());