Back to index

cell-binutils  2.17cvs20070401
Classes | Typedefs | Functions
ternary.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct  ternary_node_def


typedef struct ternary_node_defternary_tree
typedef struct ternary_node_def ternary_node


void * ternary_insert (ternary_tree *p, const char *s, void *data, int replace)
void ternary_cleanup (ternary_tree p)
void * ternary_search (const ternary_node *p, const char *s)

Class Documentation

struct ternary_node_def

Definition at line 27 of file ternary.h.

Collaboration diagram for ternary_node_def:
Class Members
ternary_tree eqkid
ternary_tree hikid
ternary_tree lokid
char splitchar

Typedef Documentation

Definition at line 25 of file ternary.h.

Function Documentation

Definition at line 97 of file ternary.c.

  if (p)
      ternary_cleanup (p->lokid);
      if (p->splitchar)
       ternary_cleanup (p->eqkid);
      ternary_cleanup (p->hikid);
      free (p);

Here is the call graph for this function:

Here is the caller graph for this function:

void* ternary_insert ( ternary_tree p,
const char *  s,
void *  data,
int  replace 
void* ternary_search ( const ternary_node p,
const char *  s 

Definition at line 111 of file ternary.c.

  const ternary_node *curr;
  int diff, spchar;
  spchar = *s;
  curr = p;
  /* Loop while we haven't hit a NULL node or returned */
  while (curr)
      /* Calculate the difference */
      diff = spchar - curr->splitchar;
      /* Handle the equal case */
      if (diff == 0)
         if (spchar == 0)
           return (PTR) curr->eqkid;
         spchar = *++s;
         curr = curr->eqkid;
      /* Handle the less than case */
      else if (diff < 0)
       curr = curr->lokid;
      /* All that's left is greater than */
       curr = curr->hikid;
  return NULL;

Here is the call graph for this function: