| 1 | #if !defined TREEBUFFER_H
|
|---|
| 2 | #define TREEBUFFER_H
|
|---|
| 3 |
|
|---|
| 4 | //#include <stdio.h>
|
|---|
| 5 |
|
|---|
| 6 | enum algo { tb_naive = 0, tb_gc, tb_amortized, tb_real_time };
|
|---|
| 7 |
|
|---|
| 8 | typedef struct Node Node;
|
|---|
| 9 | typedef struct Tree Tree;
|
|---|
| 10 |
|
|---|
| 11 | //Node * tb_make_node(int data);
|
|---|
| 12 | //int tb_get_data(Node * node);
|
|---|
| 13 | //Tree * tb_initialize(int history, enum algo algo, Node * root);
|
|---|
| 14 | void delete(Tree * tree);
|
|---|
| 15 |
|
|---|
| 16 | /* NOTE: The client must allocate/deallocate the 0-terminated arrays |children|
|
|---|
| 17 | and |ancestors| that appear below. In contrast, clients allocate but do not
|
|---|
| 18 | deallocate |Node|s. */
|
|---|
| 19 |
|
|---|
| 20 | //void tb_add_child(Tree * tree, Node * parent, Node * child);
|
|---|
| 21 | //void tb_deactivate(Tree * tree, Node * node);
|
|---|
| 22 | //void tb_expand(Tree * tree, Node * parent, Node * children[]);
|
|---|
| 23 | //void tb_history(Tree * tree, Node * node, Node * ancestors[]);
|
|---|
| 24 | /* history of |node| is put in |ancestors|, which is 0-terminated;
|
|---|
| 25 | |node| must be active */
|
|---|
| 26 |
|
|---|
| 27 | /* Added for verifyThis 2017, always took "history" nodes from the
|
|---|
| 28 | last one being added and is still active: */
|
|---|
| 29 | void take(Tree * tree, Node * ancestors[]);
|
|---|
| 30 | Tree * add(Tree * tree, int data);
|
|---|
| 31 | Tree * empty(int history);
|
|---|
| 32 | int get_data(Node * node);
|
|---|
| 33 | void check_heap_inbound(size_t heap_size, int history, Tree * tree, size_t * max);
|
|---|
| 34 | //Node * tb_active(const Tree * tree);
|
|---|
| 35 | //Node * tb_next_active(const Tree * tree, const Node * node);
|
|---|
| 36 | // Intended use:
|
|---|
| 37 | // for (Node * n = tb_active(t); n; n = tb_next_active(t, n)) { ... }
|
|---|
| 38 |
|
|---|
| 39 | #endif
|
|---|