Lines Matching full:next

28 /// only have one `ListArc` (for each pair of prev/next pointers), this ensures that the same
29 /// prev/next pointers are not used for several linked lists.
35 /// * All prev/next pointers in `ListLinks` fields of items in the list are valid and form a cycle.
84 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 15);
85 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 10);
86 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 30);
87 /// assert!(iter.next().is_none());
109 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 30);
110 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 10);
111 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 15);
112 /// assert!(iter.next().is_none());
137 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 15);
138 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 25);
139 /// assert_eq!(iter.next().ok_or(EINVAL)?.value, 35);
140 /// assert!(iter.next().is_none());
202 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("a", 15));
203 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("a", 32));
204 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("b", 42));
205 /// assert!(iter.next().is_none());
227 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("b", 42));
228 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("a", 32));
229 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("a", 15));
230 /// assert!(iter.next().is_none());
255 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("b", 42));
256 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("b", 42));
257 /// assert_eq!(iter.next().ok_or(EINVAL)?.value.foo(), ("a", 25));
258 /// assert!(iter.next().is_none());
316 /// * The returned pointer is valid until the next call to `post_remove`.
361 next: *mut ListLinksFields,
365 /// The prev/next pointers for an item in a linked list.
393 next: ptr::null_mut(),
448 next: ptr::null_mut(),
480 /// Inserts `item` before `next` in the cycle.
487 /// * `next` must be an element in this list or null.
488 /// * if `next` is null, then the list must be empty.
492 next: *mut ListLinksFields,
507 if next.is_null() {
511 (*item).next = item;
518 let prev = unsafe { (*next).prev };
521 // INVARIANT: This correctly inserts `item` between `prev` and `next`.
523 (*item).next = next;
525 (*prev).next = item;
526 (*next).prev = item;
594 let ListLinksFields { next, prev } = unsafe { *item };
596 debug_assert_eq!(next.is_null(), prev.is_null());
597 if !next.is_null() {
603 // SAFETY: We just checked that `next` is not null, and it's not dangling by the
606 debug_assert_eq!(item, (*next).prev);
607 item = (*next).prev;
612 Some(unsafe { self.remove_internal_inner(item, next, prev) })
626 let ListLinksFields { next, prev } = unsafe { *item };
628 unsafe { self.remove_internal_inner(item, next, prev) }
635 /// The `item` pointer must point at an item in this list, and we must have `(*item).next ==
636 /// next` and `(*item).prev == prev`.
640 next: *mut ListLinksFields,
643 // SAFETY: We have exclusive access to the pointers of items in the list, and the prev/next
647 // * If the list has at least three items, then after removing the item, `prev` and `next`
648 // will be next to each other.
650 // * If the list has one item, then `next == prev == item`, so these writes have no
653 (*next).prev = prev;
654 (*prev).next = next;
660 (*item).next = ptr::null_mut();
665 // `prev->next` to `next`, which is the new first item, and setting `item->next` to null
666 // did not modify `prev->next`.
668 // `item->next` to null, so this correctly sets `first` to null now that the list is
674 self.first = unsafe { (*prev).next };
708 (*other_last).next = self_first;
709 (*self_last).next = other_first;
722 next: self.first,
729 // INVARIANT: `next` is allowed to be null.
731 next: core::ptr::null_mut(),
779 fn next(&mut self) -> Option<ArcBorrow<'a, T>> {
788 let next = unsafe { (*current).next };
790 // Otherwise, we update it to the next element.
791 self.current = if next != self.stop {
792 next
813 /// and next element, but no current element. It also means that it's possible to have a cursor
848 /// while let Some(next) = cursor.peek_next() {
849 /// if next.value == value {
850 /// return Some(next.remove());
874 /// while let Some(next) = cursor.peek_next() {
875 /// if next.value == value {
876 /// out.push_back(next.remove());
901 /// while let Some(next) = cursor.peek_next() {
902 /// if to_insert.value < next.value {
933 /// assert_eq!(items.next().ok_or(EINVAL)?.value, 10);
934 /// assert_eq!(items.next().ok_or(EINVAL)?.value, 11);
935 /// assert_eq!(items.next().ok_or(EINVAL)?.value, 12);
936 /// assert_eq!(items.next().ok_or(EINVAL)?.value, 13);
937 /// assert_eq!(items.next().ok_or(EINVAL)?.value, 14);
938 /// assert!(items.next().is_none());
944 /// The `next` pointer is null or points a value in `list`.
948 next: *mut ListLinksFields,
956 let mut next = self.next;
958 if next == first {
963 if next.is_null() {
966 next = first;
969 // SAFETY: `next` can't be null, because then `first` must also be null, but in that case
970 // we would have exited at the `next == first` check. Thus, `next` is an element in the
972 unsafe { (*next).prev }
977 if self.next.is_null() {
982 // * We just checked that `self.next` is non-null, so it must be in `self.list`.
983 // * `ptr` is equal to `self.next`.
985 ptr: self.next,
1000 // * `self.prev_ptr()` never returns `self.next`.
1012 if self.next.is_null() {
1016 // SAFETY: `self.next` is an element in the list and we borrow the list mutably, so we can
1017 // access the `next` field.
1018 let mut next = unsafe { (*self.next).next };
1020 if next == self.list.first {
1021 next = core::ptr::null_mut();
1024 // INVARIANT: `next` is either null or the next element after an element in the list.
1025 self.next = next;
1034 if self.next == self.list.first {
1039 self.next = self.prev_ptr();
1045 let ptr = if self.next.is_null() {
1048 self.next
1054 if self.next == self.list.first {
1066 // involves the word prev or next.
1074 self.next = self.insert_inner(item);
1084 /// Remove the next element from the list.
1095 /// References the element in the list next to the cursor.
1100 /// * `ISNEXT == (self.ptr == self.cursor.next)`.
1115 // INVARIANT: `self.ptr` is not equal to `self.cursor.next` due to the above `move_next`
1117 // SAFETY: By the type invariants of `Self`, `next` is not null, so `next` is an element of
1183 fn next(&mut self) -> Option<ListArc<T, ID>> {