Lines Matching full:cursor

718     /// Returns a cursor that points before the first element of the list.
719 pub fn cursor_front(&mut self) -> Cursor<'_, T, ID> {
721 Cursor {
727 /// Returns a cursor that points after the last element in the list.
728 pub fn cursor_back(&mut self) -> Cursor<'_, T, ID> {
730 Cursor {
810 /// A cursor into a [`List`].
812 /// A cursor always rests between two elements in the list. This means that a cursor has a previous
813 /// and next element, but no current element. It also means that it's possible to have a cursor
845 /// // Use a cursor to remove the first element with the given value.
847 /// let mut cursor = list.cursor_front();
848 /// while let Some(next) = cursor.peek_next() {
852 /// cursor.move_next();
857 /// // Use a cursor to remove the last element with the given value.
859 /// let mut cursor = list.cursor_back();
860 /// while let Some(prev) = cursor.peek_prev() {
864 /// cursor.move_prev();
869 /// // Use a cursor to remove all elements with the given value. The removed elements are moved to
873 /// let mut cursor = list.cursor_front();
874 /// while let Some(next) = cursor.peek_next() {
878 /// cursor.move_next();
884 /// // Use a cursor to insert a value at a specific index. Returns an error if the index is out of
887 /// let mut cursor = list.cursor_front();
889 /// if !cursor.move_next() {
893 /// cursor.insert_next(new);
899 /// let mut cursor = list.cursor_front();
901 /// while let Some(next) = cursor.peek_next() {
905 /// cursor.move_next();
907 /// cursor.insert_prev(to_insert);
945 pub struct Cursor<'a, T: ?Sized + ListItem<ID>, const ID: u64 = 0> {
947 /// Points at the element after this cursor, or null if the cursor is after the last element.
951 impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> Cursor<'a, T, ID> {
952 /// Returns a pointer to the element before the cursor.
954 /// Returns null if there is no element before the cursor.
975 /// Access the element after this cursor.
986 cursor: self,
990 /// Access the element before this cursor.
1003 cursor: self,
1007 /// Move the cursor one element forward.
1009 /// If the cursor is after the last element, then this call does nothing. This call returns
1010 /// `true` if the cursor's position was changed.
1029 /// Move the cursor one element backwards.
1031 /// If the cursor is before the first element, then this call does nothing. This call returns
1032 /// `true` if the cursor's position was changed.
1043 /// Inserts an element where the cursor is pointing and get a pointer to the new element.
1061 /// Insert an element at this cursor's location.
1063 // This is identical to `insert_prev`, but consumes the cursor. This is helpful because it
1064 // reduces confusion when the last operation on the cursor is an insertion; in that case,
1065 // you just want to insert the element at the cursor, and it is confusing that the call
1070 /// Inserts an element after this cursor.
1072 /// After insertion, the new element will be after the cursor.
1077 /// Inserts an element before this cursor.
1079 /// After insertion, the new element will be before the cursor.
1095 /// References the element in the list next to the cursor.
1099 /// * `ptr` is an element in `self.cursor.list`.
1100 /// * `ISNEXT == (self.ptr == self.cursor.next)`.
1102 cursor: &'a mut Cursor<'b, T, ID>,
1112 self.cursor.move_next();
1115 // INVARIANT: `self.ptr` is not equal to `self.cursor.next` due to the above `move_next`
1118 // `self.cursor.list` by the type invariants of `Cursor`.
1119 unsafe { self.cursor.list.remove_internal(self.ptr) }
1124 // SAFETY: `self.ptr` points at an element in `self.cursor.list`.
1130 // access to the `CursorPeek`, the `Cursor` or the `List`. However, the `ArcBorrow` holds
1132 // `Cursor`, which in turn holds a mutable borrow on the `List`, so any such mutable
1151 // SAFETY: `self.ptr` points at an element in `self.cursor.list`.
1156 // access to the `CursorPeek`, the `Cursor` or the `List`. However, the `&T` holds an
1158 // `Cursor`, which in turn holds a mutable borrow on the `List`, so any such mutable access