Chimera: chimera_0-8/src/jrb.c File Reference

- Main Page
- Classes
- Files
- Directories

- File List
- File Members

# jrb.c File Reference

`#include <string.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <ctype.h>`
`#include "jrb.h"`

## Defines
#define | isred(n) (n->red)
#define | isblack(n) (!isred(n))
#define | isleft(n) (n->left)
#define | isright(n) (!isleft(n))
#define | isint(n) (n->internal)
#define | isext(n) (!isint(n))
#define | ishead(n) (n->roothead & 2)
#define | isroot(n) (n->roothead & 1)
#define | getlext(n) ((struct jrb_node *)(n->key.v))
#define | setlext(node, val) node->key.v = (void *) (val)
#define | getrext(n) ((struct jrb_node *)(n->val.v))
#define | setrext(node, value) node->val.v = (void *) (value)
#define | setred(n) n->red = 1
#define | setblack(n) n->red = 0
#define | setleft(n) n->left = 1
#define | setright(n) n->left = 0
#define | sethead(n) (n->roothead |= 2)
#define | setroot(n) (n->roothead |= 1)
#define | setint(n) n->internal = 1
#define | setext(n) n->internal = 0
#define | setnormal(n) n->roothead = 0
#define | sibling(n) ((isleft(n)) ? n->parent->blink : n->parent->flink)
#define | mk_new_ext(new, kkkey, vvval)
## Functions
JRB | make_jrb ()
JRB | jrb_find_gte_str (JRB n, char *key, int *fnd)
JRB | jrb_find_str (JRB n, char *key)
JRB | jrb_find_gte_int (JRB n, int ikey, int *fnd)
JRB | jrb_find_int (JRB n, int ikey)
JRB | jrb_find_gte_dbl (JRB n, double dkey, int *fnd)
JRB | jrb_find_dbl (JRB n, double dkey)
JRB | jrb_find_gte_gen (JRB n, Jval key, int(*fxn)(Jval, Jval), int *fnd)
JRB | jrb_find_gen (JRB n, Jval key, int(*fxn)(Jval, Jval))
void | jrb_delete_node (JRB n)
int | jrb_nblack (JRB n)
int | jrb_plength (JRB n)
void | jrb_free_tree (JRB n)
Jval | jrb_val (JRB n)
JRB | jrb_insert_str (JRB tree, char *key, Jval val)
JRB | jrb_insert_int (JRB tree, int ikey, Jval val)
JRB | jrb_insert_dbl (JRB tree, double dkey, Jval val)
JRB | jrb_insert_gen (JRB tree, Jval key, Jval val, int(*func)(Jval, Jval))

## Define Documentation

#define getlext | ( | n |  | ) | ((struct jrb_node *)(n->key.v))

#define getrext | ( | n |  | ) | ((struct jrb_node *)(n->val.v))

#define isblack | ( | n |  | ) | (!isred(n))

#define isext | ( | n |  | ) | (!isint(n))

#define ishead | ( | n |  | ) | (n->roothead & 2)

#define isint | ( | n |  | ) | (n->internal)

#define isleft | ( | n |  | ) | (n->left)

#define isred | ( | n |  | ) | (n->red)

#define isright | ( | n |  | ) | (!isleft(n))

#define isroot | ( | n |  | ) | (n->roothead & 1)

#define mk_new_ext | ( | new,
|  | kkkey,
|  | vvval |  | ) |

| Value:
    {\
      new = (JRB) malloc(sizeof(struct jrb_node));\
      new->val = vvval;\
      new->key = kkkey;\
      setext(new);\
      setblack(new);\
      setnormal(new);\
    }

#define setblack | ( | n |  | ) | n->red = 0

#define setext | ( | n |  | ) | n->internal = 0

#define sethead | ( | n |  | ) | (n->roothead |= 2)

#define setint | ( | n |  | ) | n->internal = 1

#define setleft | ( | n |  | ) | n->left = 1

#define setlext | ( | node,
|  | val |  | ) | node->key.v = (void *) (val)

#define setnormal | ( | n |  | ) | n->roothead = 0

#define setred | ( | n |  | ) | n->red = 1

#define setrext | ( | node,
|  | value |  | ) | node->val.v = (void *) (value)

#define setright | ( | n |  | ) | n->left = 0

#define setroot | ( | n |  | ) | (n->roothead |= 1)

#define sibling | ( | n |  | ) | ((isleft(n)) ? n->parent->blink : n->parent->flink)

## Function Documentation

void jrb_delete_node | ( | JRB | n | ) |

JRB jrb_find_dbl | ( | JRB | n,
|  | double | dkey
| ) |

JRB jrb_find_gen | ( | JRB | n,
|  | Jval | key,
|  | int(*)(Jval, Jval) | fxn
| ) |

JRB jrb_find_gte_dbl | ( | JRB | n,
|  | double | dkey,
|  | int * | fnd
| ) |

JRB jrb_find_gte_gen | ( | JRB | n,
|  | Jval | key,
|  | int(*)(Jval, Jval) | fxn,
|  | int * | fnd
| ) |

JRB jrb_find_gte_int | ( | JRB | n,
|  | int | ikey,
|  | int * | fnd
| ) |

JRB jrb_find_gte_str | ( | JRB | n,
|  | char * | key,
|  | int * | fnd
| ) |

JRB jrb_find_int | ( | JRB | n,
|  | int | ikey
| ) |

JRB jrb_find_str | ( | JRB | n,
|  | char * | key
| ) |

void jrb_free_tree | ( | JRB | n | ) |

JRB jrb_insert_dbl | ( | JRB | tree,
|  | double | dkey,
|  | Jval | val
| ) |

JRB jrb_insert_gen | ( | JRB | tree,
|  | Jval | key,
|  | Jval | val,
|  | int(*)(Jval, Jval) | func
| ) |

JRB jrb_insert_int | ( | JRB | tree,
|  | int | ikey,
|  | Jval | val
| ) |

JRB jrb_insert_str | ( | JRB | tree,
|  | char * | key,
|  | Jval | val
| ) |

int jrb_nblack | ( | JRB | n | ) |

int jrb_plength | ( | JRB | n | ) |

Jval jrb_val | ( | JRB | n | ) |

JRB make_jrb | ( |  | ) |