unsafe fn merge_sorted_list(
        &mut self,
        mut self_head: AVLNodePtr,
        mut other_head: AVLNodePtr,
    ) -> (AVLNodePtr, usize) {
        let mut cnt = 0;
        let mut head = ptr::null_mut();
        let mut prev = ptr::null_mut() as AVLNodePtr;
        while self_head.not_null() || other_head.not_null() {
            let left_entry = self_head.avl_node_deref_to_entry::<K, V>();
            let right_entry = other_head.avl_node_deref_to_entry::<K, V>();
            let res = if self_head.not_null() && other_head.not_null() {
                (*left_entry.key()).cmp(&*right_entry.key())
            } else if self_head.not_null() {
                Ordering::Less
            } else {
                Ordering::Greater
            };
            cnt += 1;
            let node = match res {
                Ordering::Less => {
                    let ret = self_head;
                    self_head = self_head.right();
                    ret
                }
                Ordering::Greater => {
                    let ret = other_head;
                    other_head = other_head.right();
                    ret
                }
                Ordering::Equal => {
                    let ret = other_head;
                    self_head = self_head.right();
                    other_head = other_head.right();
                    ptr::drop_in_place(left_entry);
                    self.entry_fastbin.del(left_entry as VoidPtr);
                    ret
                }
            };
            node.set_left(prev);
            node.set_right(ptr::null_mut());
            if prev.is_null() {
                head = node;
            } else {
                prev.set_right(node);
            }
            prev = node;
        }
        (head, cnt)
    }
/// Merge two sorted lists into one list. Drop the element of `self_head` if keys collide.
Merge two sorted lists into one list. Drop the element of `self_head` if keys collide.
Merge two sorted lists into one list . Drop the element of ` self_head ` if keys collide .
unsafe fn merge_sorted_list(
        &mut self,
        mut self_head: AVLNodePtr,
        mut other_head: AVLNodePtr,
    ) -> (AVLNodePtr, usize) {
        let mut cnt = 0;
        let mut head = ptr::null_mut();
        let mut prev = ptr::null_mut() as AVLNodePtr;
        while self_head.not_null() || other_head.not_null() {
            let left_entry = self_head.avl_node_deref_to_entry::<K, V>();
            let right_entry = other_head.avl_node_deref_to_entry::<K, V>();
            let res = if self_head.not_null() && other_head.not_null() {
                (*left_entry.key()).cmp(&*right_entry.key())
            } else if self_head.not_null() {
                Ordering::Less
            } else {
                Ordering::Greater
            };
            cnt += 1;
            let node = match res {
                Ordering::Less => {
                    let ret = self_head;
                    self_head = self_head.right();
                    ret
                }
                Ordering::Greater => {
                    let ret = other_head;
                    other_head = other_head.right();
                    ret
                }
                Ordering::Equal => {
                    let ret = other_head;
                    self_head = self_head.right();
                    other_head = other_head.right();
                    ptr::drop_in_place(left_entry);
                    self.entry_fastbin.del(left_entry as VoidPtr);
                    ret
                }
            };
            node.set_left(prev);
            node.set_right(ptr::null_mut());
            if prev.is_null() {
                head = node;
            } else {
                prev.set_right(node);
            }
            prev = node;
        }
        (head, cnt)
    }
unsafe fn merge_sorted_list ( & mut self , mut self_head : AVLNodePtr , mut other_head : AVLNodePtr , ) -> ( AVLNodePtr , usize ) { let mut cnt = 0 ; let mut head = ptr :: null_mut ( ) ; let mut prev = ptr :: null_mut ( ) as AVLNodePtr ; while self_head . not_null ( ) || other_head . not_null ( ) { let left_entry = self_head . avl_node_deref_to_entry :: < K , V > ( ) ; let right_entry = other_head . avl_node_deref_to_entry :: < K , V > ( ) ; let res = if self_head . not_null ( ) && other_head . not_null ( ) { ( * left_entry . key ( ) ) . cmp ( & * right_entry . key ( ) ) } else if self_head . not_null ( ) { Ordering :: Less } else { Ordering :: Greater } ; cnt += 1 ; let node = match res { Ordering :: Less => { let ret = self_head ; self_head = self_head . right ( ) ; ret } Ordering :: Greater => { let ret = other_head ; other_head = other_head . right ( ) ; ret } Ordering :: Equal => { let ret = other_head ; self_head = self_head . right ( ) ; other_head = other_head . right ( ) ; ptr :: drop_in_place ( left_entry ) ; self . entry_fastbin . del ( left_entry as VoidPtr ) ; ret } } ; node . set_left ( prev ) ; node . set_right ( ptr :: null_mut ( ) ) ; if prev . is_null ( ) { head = node ; } else { prev . set_right ( node ) ; } prev = node ; } ( head , cnt ) }
Merge two sorted lists into one list.
Merge two sorted lists into one list .
&mut self
self_head
AVLNodePtr
other_head
AVLNodePtr