version 1.12, 2015/02/18 15:32:37 |
version 1.13, 2015/10/27 15:58:42 |
|
|
* a red-black tree. |
* a red-black tree. |
*/ |
*/ |
|
|
|
struct options { |
|
RB_HEAD(options_tree, options_entry) tree; |
|
struct options *parent; |
|
}; |
|
|
|
int options_cmp(struct options_entry *, struct options_entry *); |
|
RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp); |
RB_GENERATE(options_tree, options_entry, entry, options_cmp); |
RB_GENERATE(options_tree, options_entry, entry, options_cmp); |
|
|
int |
int |
|
|
return (strcmp(o1->name, o2->name)); |
return (strcmp(o1->name, o2->name)); |
} |
} |
|
|
void |
struct options * |
options_init(struct options *oo, struct options *parent) |
options_create(struct options *parent) |
{ |
{ |
|
struct options *oo; |
|
|
|
oo = xcalloc(1, sizeof *oo); |
RB_INIT(&oo->tree); |
RB_INIT(&oo->tree); |
oo->parent = parent; |
oo->parent = parent; |
|
return (oo); |
} |
} |
|
|
void |
void |
|
|
free(o->str); |
free(o->str); |
free(o); |
free(o); |
} |
} |
|
free(oo); |
|
} |
|
|
|
struct options_entry * |
|
options_first(struct options *oo) |
|
{ |
|
return (RB_MIN(options_tree, &oo->tree)); |
|
} |
|
|
|
struct options_entry * |
|
options_next(struct options_entry *o) |
|
{ |
|
return (RB_NEXT(options_tree, &oo->tree, o)); |
} |
} |
|
|
struct options_entry * |
struct options_entry * |