Struct grove::trees::slice::Slice [−][src]
pub struct Slice<'a, D, T, L> { /* fields omitted */ }
Expand description
Returns a value representing a specific subsegment of the tree. This gives a nicer
Interface for tree operations: tree.slice(3..50).act(action)
instead of
tree.act_segment(3..50, action)
.
It allows to query the tree for a summary or to apply an action, and other useful operations, with a nicer interface.
This struct essentially just forwards calls, mostly to the methods in the traits in crate::trees
.
Implementations
Creates a new slice that represents the locator’s segment in the tree.
Finds any node in the current subsegment. If there isn’t any, it finds the empty location where that node would be instead. Returns a walker at the wanted position.
pub fn iter(self) -> IterLocator<'a, D, L, T::TreeData>ⓘNotable traits for IterLocator<'a, D, L, T>impl<'a, D: Data, L: Locator<D>, T> Iterator for IterLocator<'a, D, L, T> type Item = &'a D::Value;
pub fn iter(self) -> IterLocator<'a, D, L, T::TreeData>ⓘNotable traits for IterLocator<'a, D, L, T>impl<'a, D: Data, L: Locator<D>, T> Iterator for IterLocator<'a, D, L, T> type Item = &'a D::Value;
impl<'a, D: Data, L: Locator<D>, T> Iterator for IterLocator<'a, D, L, T> type Item = &'a D::Value;
Iterating on values. This iterator assumes you won’t change the values using interior mutability. If you change the values, The tree summaries will behave incorrectly.
The iterator receives a &mut self
argument instead of a &self
argument.
Because of the way the trees work, immutable iterators can’t be written without either mutable access
to the tree, or assuming that the values are Clone
.
On the other hand, mutable iterators can’t be written because the values of the nodes must be rebuilt, but they can only be rebuilt after the iterator exits. (This is because rust iterators can’t be streaming iterators). If you want a mutable iterator, use a walker instead.
Assumes that the this subsegment is empty.
Inserts the value into the tree into the position of this empty subsegment.
If the current subsegment is not empty, returns None
.
pub fn split_right(
&mut self
) -> Option<<<&mut T as SplittableTreeRef<D>>::SplittableWalker as SplittableWalker<D>>::T>
pub fn split_right(
&mut self
) -> Option<<<&mut T as SplittableTreeRef<D>>::SplittableWalker as SplittableWalker<D>>::T>
Assumes that the this subsegment is empty.
Split out everything to the right of this subsegment, if it is an empty subsegment.
Otherwise returns None
.
pub fn split_left(
&mut self
) -> Option<<<&mut T as SplittableTreeRef<D>>::SplittableWalker as SplittableWalker<D>>::T>
pub fn split_left(
&mut self
) -> Option<<<&mut T as SplittableTreeRef<D>>::SplittableWalker as SplittableWalker<D>>::T>
Assumes that the this subsegment is empty.
Split out everything to the left of the this subsegment, if it is an empty subsegment.
Otherwise returns None
.