www.delorie.com/gnu/docs/avl/libavl_170.html   search  
 
Buy GNU books!


GNU libavl 2.0.1

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.1 Data Types

To make a RB tree node structure into a threaded RB tree node structure, we just add a pair of tag fields. We also reintroduce a maximum height definition here. It is not used by traversers, only by by the default versions of trb_probe() and trb_delete(), for maximum efficiency.

 
/* Color of a red-black node. */
enum trb_color 
{ TRB_BLACK, /* Black. */ TRB_RED /* Red. */ }; /* Characterizes a link as a child pointer or a thread. */ enum trb_tag
{ TRB_CHILD, /* Child pointer. */ TRB_THREAD /* Thread. */ }; /* An TRB tree node. */ struct trb_node
{ struct trb_node *trb_link[2]; /* Subtrees. */ void *trb_data; /* Pointer to data. */ unsigned char trb_color; /* Color. */ unsigned char trb_tag[2]; /* Tag fields. */ };
This code is included in @refalso{333


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003