hmmer-3.3/easel/esl_red_black.c
// Recursion function used by convert_to_sorted_linked. Using a separate recursion 
// function allows us to do argument checking when the main function is called
// without having to repeat the argument check on each recursive sub-call. 
Recursion function used by convert_to_sorted_linked. Using a separate recursion
function allows us to do argument checking when the main function is called
without having to repeat the argument check on each recursive sub-call.
Recursion function used by convert_to_sorted_linked . Using a separate recursion function allows us to do argument checking when the main function is called without having to repeat the argument check on each recursive sub - call .
static int esl_red_black_doublekey_convert_to_sorted_linked_recurse(ESL_RED_BLACK_DOUBLEKEY *tree, ESL_RED_BLACK_DOUBLEKEY **head, ESL_RED_BLACK_DOUBLEKEY **tail){
  if(tree == NULL){
    return eslOK; 
  }
    esl_red_black_doublekey_convert_to_sorted_linked_recurse(tree->large, head, tail);
    if(*tail != NULL){ 
        tree->large = *tail; 
        (*tail)->small = tree;
    }
    if(*head == NULL){ 
        *head = tree;
    }
    *tail = tree; 
    esl_red_black_doublekey_convert_to_sorted_linked_recurse(tree->small, head, tail);
    return eslOK;
}
static int esl_red_black_doublekey_convert_to_sorted_linked_recurse ( ESL_RED_BLACK_DOUBLEKEY * tree , ESL_RED_BLACK_DOUBLEKEY * * head , ESL_RED_BLACK_DOUBLEKEY * * tail ) { if ( tree == NULL ) { return eslOK ; } esl_red_black_doublekey_convert_to_sorted_linked_recurse ( tree -> large , head , tail ) ; if ( * tail != NULL ) { tree -> large = * tail ; ( * tail ) -> small = tree ; } if ( * head == NULL ) { * head = tree ; } * tail = tree ; esl_red_black_doublekey_convert_to_sorted_linked_recurse ( tree -> small , head , tail ) ; return eslOK ; }
Recursion function used by convert_to_sorted_linked.
Recursion function used by convert_to_sorted_linked .
// Passing NULL tree to the recursion is fine, just means  // we've hit a leaf // recursively sort the large side of the tree // add the current node to the sorted list // there was a large sub-tree of the original tree // node's key must be smaller than anything in its large sub-tree // there weren't any nodes with larger keys than the root //root of the tree is now the smallest node in the list