Lines Matching defs:current

249         let current = unsafe { bindings::rb_first(root) };
250 NonNull::new(current).map(|current| {
252 // - `current` is a valid node in the [`RBTree`] pointed to by `self`.
254 current,
264 let current = unsafe { bindings::rb_first(root) };
265 NonNull::new(current).map(|current| {
267 // - `current` is a valid node in the [`RBTree`] pointed to by `self`.
269 current,
279 let current = unsafe { bindings::rb_last(root) };
280 NonNull::new(current).map(|current| {
282 // - `current` is a valid node in the [`RBTree`] pointed to by `self`.
284 current,
294 let current = unsafe { bindings::rb_last(root) };
295 NonNull::new(current).map(|current| {
297 // - `current` is a valid node in the [`RBTree`] pointed to by `self`.
299 current,
463 NonNull::new(best.as_ptr()).map(|current| {
465 // - `current` is a valid node in the [`RBTree`] pointed to by `self`.
467 current,
484 NonNull::new(best.as_ptr()).map(|current| {
486 // - `current` is a valid node in the [`RBTree`] pointed to by `self`.
488 current,
551 // Find out what the next node is before disposing of the current one.
584 /// let mut current = cursor.current();
585 /// assert_eq!(current, (&10, &100));
589 /// current = cursor.current();
590 /// assert_eq!(current, (&20, &200));
595 /// current = cursor.current();
596 /// assert_eq!(current, (&20, &200));
600 /// current = cursor.current();
601 /// assert_eq!(current, (&30, &300));
622 /// let current = cursor.current();
623 /// assert_eq!(current, (&30, &300));
656 /// let current = cursor.current();
657 /// assert_eq!(current, (&20, &200));
661 /// let current = cursor.current();
662 /// assert_eq!(current, (&30, &300));
687 /// // Get a mutable reference to the current value.
698 /// It also allows node removal. The following examples demonstrate the behavior of removing the current node.
713 /// let mut current = cursor.current();
714 /// assert_eq!(current, (&10, &100));
717 /// // If a node exists after the current element, it is returned.
718 /// current = cursor.current();
719 /// assert_eq!(current, (&20, &200));
723 /// current = cursor.current();
724 /// assert_eq!(current, (&30, &300));
728 /// current = cursor.current();
729 /// assert_eq!(current, (&20, &200));
737 /// Nodes adjacent to the current node can also be removed.
752 /// let mut current = cursor.current();
753 /// assert_eq!(current, (&10, &100));
760 /// current = cursor.current();
761 /// assert_eq!(current, (&30, &300));
771 /// current = cursor.current();
772 /// assert_eq!(current, (&10, &100));
782 /// - `current` points to a node that is in the same [`RBTree`] as `tree`.
785 current: NonNull<bindings::rb_node>,
809 /// let current = cursor.current();
810 /// assert_eq!(current, (&10, &100));
816 current: NonNull<bindings::rb_node>,
828 /// The current node
829 pub fn current(&self) -> (&K, &V) {
831 // - `self.current` is a valid node by the type invariants.
833 unsafe { Self::to_key_value(self.current) }
844 // SAFETY: The passed `node` is the current node or a non-null neighbor,
847 // SAFETY: The passed `node` is the current node or a non-null neighbor,
873 // SAFETY: `self.current` is valid by the type invariants.
876 Direction::Prev => bindings::rb_prev(self.current.as_ptr()),
877 Direction::Next => bindings::rb_next(self.current.as_ptr()),
897 /// The current node.
898 pub fn current(&self) -> (&K, &V) {
900 // - `self.current` is a valid node by the type invariants.
902 unsafe { Self::to_key_value(self.current) }
905 /// The current node, with a mutable value
908 // - `self.current` is a valid node by the type invariants.
910 unsafe { Self::to_key_value_mut(self.current) }
913 /// Remove the current node from the tree.
923 let this = unsafe { container_of!(self.current.as_ptr(), Node<K, V>, links) };
932 // - `current` is a valid node in the [`RBTree`] pointed to by `self.tree`.
933 let cursor = next.or(prev).map(|current| Self {
934 current,
982 current: neighbor,
1025 // SAFETY: `self.current` is valid by the type invariants.
1028 Direction::Prev => bindings::rb_prev(self.current.as_ptr()),
1029 Direction::Next => bindings::rb_next(self.current.as_ptr()),
1066 // SAFETY: The passed `node` is the current node or a non-null neighbor,
1069 // SAFETY: The passed `node` is the current node or a non-null neighbor,
1404 /// Swap the current node for the provided node.