Lines Matching refs:V

172 pub struct RBTree<K, V> {
174 _p: PhantomData<Node<K, V>>,
179 unsafe impl<K: Send, V: Send> Send for RBTree<K, V> {}
183 unsafe impl<K: Sync, V: Sync> Sync for RBTree<K, V> {}
185 impl<K, V> RBTree<K, V> {
196 pub fn iter(&self) -> Iter<'_, K, V> { in iter() argument
211 pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { in iter_mut() argument
231 pub fn values(&self) -> impl Iterator<Item = &'_ V> { in values()
236 pub fn values_mut(&mut self) -> impl Iterator<Item = &'_ mut V> { in values_mut()
241 pub fn cursor_front(&mut self) -> Option<Cursor<'_, K, V>> { in cursor_front() argument
256 pub fn cursor_back(&mut self) -> Option<Cursor<'_, K, V>> { in cursor_back() argument
271 impl<K, V> RBTree<K, V>
284 value: V, in try_create_and_insert() argument
286 ) -> Result<Option<RBTreeNode<K, V>>> { in try_create_and_insert() argument
296 pub fn insert(&mut self, node: RBTreeNode<K, V>) -> Option<RBTreeNode<K, V>> { in insert() argument
306 fn raw_entry(&mut self, key: &K) -> RawEntry<'_, K, V> { in raw_entry() argument
307 let raw_self: *mut RBTree<K, V> = self; in raw_entry()
333 let node = unsafe { container_of!(curr, Node<K, V>, links) }; in raw_entry()
360 pub fn entry(&mut self, key: K) -> Entry<'_, K, V> { in entry() argument
368 pub fn find_mut(&mut self, key: &K) -> Option<OccupiedEntry<'_, K, V>> { in find_mut() argument
376 pub fn get(&self, key: &K) -> Option<&V> { in get() argument
381 let this = unsafe { container_of!(node, Node<K, V>, links) }; in get()
396 pub fn get_mut(&mut self, key: &K) -> Option<&mut V> { in get_mut() argument
403 pub fn remove_node(&mut self, key: &K) -> Option<RBTreeNode<K, V>> { in remove_node() argument
410 pub fn remove(&mut self, key: &K) -> Option<V> { in remove() argument
419 pub fn cursor_lower_bound(&mut self, key: &K) -> Option<Cursor<'_, K, V>> in cursor_lower_bound()
424 let mut best_match: Option<NonNull<Node<K, V>>> = None; in cursor_lower_bound()
428 let this = unsafe { container_of!(node, Node<K, V>, links) }.cast_mut(); in cursor_lower_bound()
476 impl<K, V> Default for RBTree<K, V> {
482 impl<K, V> Drop for RBTree<K, V> {
490 let this = unsafe { container_of!(next, Node<K, V>, links) }; in drop()
724 pub struct Cursor<'a, K, V> {
725 tree: &'a mut RBTree<K, V>,
732 unsafe impl<'a, K: Send, V: Send> Send for Cursor<'a, K, V> {}
736 unsafe impl<'a, K: Sync, V: Sync> Sync for Cursor<'a, K, V> {}
738 impl<'a, K, V> Cursor<'a, K, V> {
740 pub fn current(&self) -> (&K, &V) { in current() argument
748 pub fn current_mut(&mut self) -> (&K, &mut V) { in current_mut() argument
760 pub fn remove_current(self) -> (Option<Self>, RBTreeNode<K, V>) { in remove_current() argument
765 let this = unsafe { container_of!(self.current.as_ptr(), Node<K, V>, links) }.cast_mut(); in remove_current()
793 pub fn remove_prev(&mut self) -> Option<RBTreeNode<K, V>> { in remove_prev() argument
798 pub fn remove_next(&mut self) -> Option<RBTreeNode<K, V>> { in remove_next() argument
802 fn remove_neighbor(&mut self, direction: Direction) -> Option<RBTreeNode<K, V>> { in remove_neighbor() argument
810 let this = unsafe { container_of!(neighbor, Node<K, V>, links) }.cast_mut(); in remove_neighbor()
838 pub fn peek_prev(&self) -> Option<(&K, &V)> { in peek_prev() argument
843 pub fn peek_next(&self) -> Option<(&K, &V)> { in peek_next() argument
847 fn peek(&self, direction: Direction) -> Option<(&K, &V)> { in peek() argument
857 pub fn peek_prev_mut(&mut self) -> Option<(&K, &mut V)> { in peek_prev_mut() argument
862 pub fn peek_next_mut(&mut self) -> Option<(&K, &mut V)> { in peek_next_mut() argument
866 fn peek_mut(&mut self, direction: Direction) -> Option<(&K, &mut V)> { in peek_mut() argument
890 unsafe fn to_key_value<'b>(node: NonNull<bindings::rb_node>) -> (&'b K, &'b V) { in to_key_value() argument
900 unsafe fn to_key_value_mut<'b>(node: NonNull<bindings::rb_node>) -> (&'b K, &'b mut V) { in to_key_value_mut() argument
910 unsafe fn to_key_value_raw<'b>(node: NonNull<bindings::rb_node>) -> (&'b K, *mut V) { in to_key_value_raw() argument
913 let this = unsafe { container_of!(node.as_ptr(), Node<K, V>, links) }.cast_mut(); in to_key_value_raw()
932 impl<'a, K, V> IntoIterator for &'a RBTree<K, V> {
933 type Item = (&'a K, &'a V);
934 type IntoIter = Iter<'a, K, V>;
944 pub struct Iter<'a, K, V> {
945 _tree: PhantomData<&'a RBTree<K, V>>,
946 iter_raw: IterRaw<K, V>,
951 unsafe impl<'a, K: Sync, V: Sync> Send for Iter<'a, K, V> {}
955 unsafe impl<'a, K: Sync, V: Sync> Sync for Iter<'a, K, V> {}
957 impl<'a, K, V> Iterator for Iter<'a, K, V> {
958 type Item = (&'a K, &'a V);
966 impl<'a, K, V> IntoIterator for &'a mut RBTree<K, V> {
967 type Item = (&'a K, &'a mut V);
968 type IntoIter = IterMut<'a, K, V>;
978 pub struct IterMut<'a, K, V> {
979 _tree: PhantomData<&'a mut RBTree<K, V>>,
980 iter_raw: IterRaw<K, V>,
986 unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {}
990 unsafe impl<'a, K: Sync, V: Sync> Sync for IterMut<'a, K, V> {}
992 impl<'a, K, V> Iterator for IterMut<'a, K, V> {
993 type Item = (&'a K, &'a mut V);
1007 struct IterRaw<K, V> {
1009 _phantom: PhantomData<fn() -> (K, V)>,
1012 impl<K, V> Iterator for IterRaw<K, V> {
1013 type Item = (*mut K, *mut V);
1022 let cur = unsafe { container_of!(self.next, Node<K, V>, links) }.cast_mut(); in next()
1037 pub struct RBTreeNodeReservation<K, V> {
1038 node: Box<MaybeUninit<Node<K, V>>>,
1041 impl<K, V> RBTreeNodeReservation<K, V> {
1044 pub fn new(flags: Flags) -> Result<RBTreeNodeReservation<K, V>> { in new() argument
1053 unsafe impl<K, V> Send for RBTreeNodeReservation<K, V> {}
1056 unsafe impl<K, V> Sync for RBTreeNodeReservation<K, V> {}
1058 impl<K, V> RBTreeNodeReservation<K, V> {
1062 pub fn into_node(mut self, key: K, value: V) -> RBTreeNode<K, V> { in into_node() argument
1078 pub struct RBTreeNode<K, V> {
1079 node: Box<Node<K, V>>,
1082 impl<K, V> RBTreeNode<K, V> {
1085 pub fn new(key: K, value: V, flags: Flags) -> Result<RBTreeNode<K, V>> { in new() argument
1090 pub fn to_key_value(self) -> (K, V) { in to_key_value() argument
1097 unsafe impl<K: Send, V: Send> Send for RBTreeNode<K, V> {}
1101 unsafe impl<K: Sync, V: Sync> Sync for RBTreeNode<K, V> {}
1103 impl<K, V> RBTreeNode<K, V> {
1111 pub fn into_reservation(self) -> RBTreeNodeReservation<K, V> { in into_reservation() argument
1123 pub enum Entry<'a, K, V> {
1125 Vacant(VacantEntry<'a, K, V>),
1127 Occupied(OccupiedEntry<'a, K, V>),
1131 enum RawEntry<'a, K, V> {
1132 Vacant(RawVacantEntry<'a, K, V>),
1133 Occupied(OccupiedEntry<'a, K, V>),
1137 pub struct VacantEntry<'a, K, V> {
1139 raw: RawVacantEntry<'a, K, V>,
1148 struct RawVacantEntry<'a, K, V> {
1149 rbtree: *mut RBTree<K, V>,
1155 _phantom: PhantomData<&'a mut RBTree<K, V>>,
1158 impl<'a, K, V> RawVacantEntry<'a, K, V> {
1163 fn insert(self, node: RBTreeNode<K, V>) -> &'a mut V { in insert() argument
1183 impl<'a, K, V> VacantEntry<'a, K, V> {
1185 pub fn insert(self, value: V, reservation: RBTreeNodeReservation<K, V>) -> &'a mut V { in insert() argument
1194 pub struct OccupiedEntry<'a, K, V> {
1195 rbtree: &'a mut RBTree<K, V>,
1200 impl<'a, K, V> OccupiedEntry<'a, K, V> {
1202 pub fn get(&self) -> &V { in get() argument
1206 unsafe { &(*container_of!(self.node_links, Node<K, V>, links)).value } in get()
1210 pub fn get_mut(&mut self) -> &mut V { in get_mut() argument
1214 unsafe { &mut (*(container_of!(self.node_links, Node<K, V>, links).cast_mut())).value } in get_mut()
1220 pub fn into_mut(self) -> &'a mut V { in into_mut() argument
1224 unsafe { &mut (*(container_of!(self.node_links, Node<K, V>, links).cast_mut())).value } in into_mut()
1228 pub fn remove_node(self) -> RBTreeNode<K, V> { in remove_node() argument
1238 Box::from_raw(container_of!(self.node_links, Node<K, V>, links).cast_mut()) in remove_node()
1244 pub fn remove(self) -> V { in remove() argument
1251 fn replace(self, node: RBTreeNode<K, V>) -> RBTreeNode<K, V> { in replace() argument
1268 unsafe { Box::from_raw(container_of!(self.node_links, Node<K, V>, links).cast_mut()) }; in replace()
1274 struct Node<K, V> {
1277 value: V,