hmmer-3.3/easel/esl_red_black.c
// Converts the input red-black tree into a doubly-linked list.  Returns eslOK if the conversion
// succeeded.  Returns a pointer to the node with the largest key in head, a pointer to the node
// with the smallest key in tail
// Code based on algorithm from http://www.geeksforgeeks.org/convert-a-given-binary-tree-to-doubly-linked-list-set-4/
Converts the input red-black tree into a doubly-linked list.  Returns eslOK if the conversion
succeeded.
Converts the input red - black tree into a doubly - linked list . Returns eslOK if the conversion succeeded .
int esl_red_black_doublekey_convert_to_sorted_linked(ESL_RED_BLACK_DOUBLEKEY *tree, ESL_RED_BLACK_DOUBLEKEY **head, ESL_RED_BLACK_DOUBLEKEY **tail){
  if(tree == NULL){
    return eslFAIL; 
    }
  *head = NULL;
  *tail = NULL;
  esl_red_black_doublekey_convert_to_sorted_linked_recurse(tree, head, tail);
  return eslOK;
}
int esl_red_black_doublekey_convert_to_sorted_linked ( ESL_RED_BLACK_DOUBLEKEY * tree , ESL_RED_BLACK_DOUBLEKEY * * head , ESL_RED_BLACK_DOUBLEKEY * * tail ) { if ( tree == NULL ) { return eslFAIL ; } * head = NULL ; * tail = NULL ; esl_red_black_doublekey_convert_to_sorted_linked_recurse ( tree , head , tail ) ; return eslOK ; }
Converts the input red-black tree into a doubly-linked list.
Converts the input red - black tree into a doubly - linked list .
// Can't proceed with a NULL base tree // clear the head and tail pointers to avoid confusion if they were previously used /*// recursively sort the large side of the tree
  esl_red_black_doublekey_convert_to_sorted_linked_recurse(tree->large, head, tail);

  // add the current node to the sorted list
  
  if(*tail != NULL){ // there was a large sub-tree of the original tree
        tree->large = *tail; // node's key must be smaller than anything in its large sub-tree
        (*tail)->small = tree;
  }
    
  if(*head == NULL){ // there weren't any nodes with larger keys than the root
    *head = tree;
  }
  *tail = tree; //root of the tree is now the smallest node in the list

  esl_red_black_doublekey_convert_to_sorted_linked_recurse(tree->small, head, tail);
  */