pub struct CursorMut<'a, K, A = Global>where
K: 'a,{ /* private fields */ }btree_cursors)Expand description
A cursor over a BTreeSet with editing operations.
A Cursor is like an iterator, except that it can freely seek back-and-forth, and can
safely mutate the set during iteration. This is because the lifetime of its yielded
references is tied to its own lifetime, instead of just the underlying map. This means
cursors cannot yield multiple elements at once.
Cursors always point to a gap between two elements in the set, and can operate on the two immediately adjacent elements.
A CursorMut is created with the BTreeSet::lower_bound_mut and BTreeSet::upper_bound_mut
methods.
Implementationsยง
Sourceยงimpl<'a, T, A> CursorMut<'a, T, A>
impl<'a, T, A> CursorMut<'a, T, A>
Sourcepub fn next(&mut self) -> Option<&T>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn next(&mut self) -> Option<&T>
btree_cursors)Advances the cursor to the next gap, returning the element that it moved over.
If the cursor is already at the end of the set then None is returned
and the cursor is not moved.
Sourcepub fn prev(&mut self) -> Option<&T>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn prev(&mut self) -> Option<&T>
btree_cursors)Advances the cursor to the previous gap, returning the element that it moved over.
If the cursor is already at the start of the set then None is returned
and the cursor is not moved.
Sourcepub fn peek_next(&mut self) -> Option<&T>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn peek_next(&mut self) -> Option<&T>
btree_cursors)Returns a reference to the next element without moving the cursor.
If the cursor is at the end of the set then None is returned.
Sourcepub fn peek_prev(&mut self) -> Option<&T>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn peek_prev(&mut self) -> Option<&T>
btree_cursors)Returns a reference to the previous element without moving the cursor.
If the cursor is at the start of the set then None is returned.
Sourcepub fn as_cursor(&self) -> Cursor<'_, T>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn as_cursor(&self) -> Cursor<'_, T>
btree_cursors)Returns a read-only cursor pointing to the same location as the
CursorMut.
The lifetime of the returned Cursor is bound to that of the
CursorMut, which means it cannot outlive the CursorMut and that the
CursorMut is frozen for the lifetime of the Cursor.
Sourcepub unsafe fn with_mutable_key(self) -> CursorMutKey<'a, T, A>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub unsafe fn with_mutable_key(self) -> CursorMutKey<'a, T, A>
btree_cursors)Converts the cursor into a CursorMutKey, which allows mutating
elements in the tree.
ยงSafety
Since this cursor allows mutating elements, you must ensure that the
BTreeSet invariants are maintained. Specifically:
- The newly inserted element must be unique in the tree.
- All elements in the tree must remain in sorted order.
Sourceยงimpl<'a, T, A> CursorMut<'a, T, A>
impl<'a, T, A> CursorMut<'a, T, A>
Sourcepub unsafe fn insert_after_unchecked(&mut self, value: T)
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub unsafe fn insert_after_unchecked(&mut self, value: T)
btree_cursors)Inserts a new element into the set in the gap that the cursor is currently pointing to.
After the insertion the cursor will be pointing at the gap before the newly inserted element.
ยงSafety
You must ensure that the BTreeSet invariants are maintained.
Specifically:
- The newly inserted element must be unique in the tree.
- All elements in the tree must remain in sorted order.
Sourcepub unsafe fn insert_before_unchecked(&mut self, value: T)
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub unsafe fn insert_before_unchecked(&mut self, value: T)
btree_cursors)Inserts a new element into the set in the gap that the cursor is currently pointing to.
After the insertion the cursor will be pointing at the gap after the newly inserted element.
ยงSafety
You must ensure that the BTreeSet invariants are maintained.
Specifically:
- The newly inserted element must be unique in the tree.
- All elements in the tree must remain in sorted order.
Sourcepub fn insert_after(&mut self, value: T) -> Result<(), UnorderedKeyError>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn insert_after(&mut self, value: T) -> Result<(), UnorderedKeyError>
btree_cursors)Inserts a new element into the set in the gap that the cursor is currently pointing to.
After the insertion the cursor will be pointing at the gap before the newly inserted element.
If the inserted element is not greater than the element before the
cursor (if any), or if it not less than the element after the cursor (if
any), then an UnorderedKeyError is returned since this would
invalidate the Ord invariant between the elements of the set.
Sourcepub fn insert_before(&mut self, value: T) -> Result<(), UnorderedKeyError>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn insert_before(&mut self, value: T) -> Result<(), UnorderedKeyError>
btree_cursors)Inserts a new element into the set in the gap that the cursor is currently pointing to.
After the insertion the cursor will be pointing at the gap after the newly inserted element.
If the inserted element is not greater than the element before the
cursor (if any), or if it not less than the element after the cursor (if
any), then an UnorderedKeyError is returned since this would
invalidate the Ord invariant between the elements of the set.
Sourcepub fn remove_next(&mut self) -> Option<T>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn remove_next(&mut self) -> Option<T>
btree_cursors)Removes the next element from the BTreeSet.
The element that was removed is returned. The cursor position is unchanged (before the removed element).
Sourcepub fn remove_prev(&mut self) -> Option<T>
๐ฌThis is a nightly-only experimental API. (btree_cursors)
pub fn remove_prev(&mut self) -> Option<T>
btree_cursors)Removes the preceding element from the BTreeSet.
The element that was removed is returned. The cursor position is unchanged (after the removed element).
Trait Implementationsยง
Auto Trait Implementationsยง
impl<'a, K, A> Freeze for CursorMut<'a, K, A>
impl<'a, K, A> RefUnwindSafe for CursorMut<'a, K, A>where
A: RefUnwindSafe,
K: RefUnwindSafe,
impl<'a, K, A> Send for CursorMut<'a, K, A>
impl<'a, K, A> Sync for CursorMut<'a, K, A>
impl<'a, K, A> Unpin for CursorMut<'a, K, A>
impl<'a, K, A> UnsafeUnpin for CursorMut<'a, K, A>
impl<'a, K, A = Global> !UnwindSafe for CursorMut<'a, K, A>
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Sourceยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Sourceยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Sourceยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.Sourceยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.Sourceยงimpl<T> DowncastSync for T
impl<T> DowncastSync for T
Sourceยงimpl<A> DynCastExt for A
impl<A> DynCastExt for A
Sourceยงfn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
fn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
Sourceยงfn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
Sourceยงfn dyn_cast_adv<F, T>(
self,
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
fn dyn_cast_adv<F, T>( self, ) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
Sourceยงfn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
fn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
Sourceยงfn in_current_span(self) -> Instrumented<Self> โ
fn in_current_span(self) -> Instrumented<Self> โ
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more