source: src/tests/avltree/avl1.c @ 175ad32b

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 175ad32b was 2afec66, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Update several tests for references

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#include "avl.h"
2// #include "cwrap.h"
3
4forall(otype K | Comparable(K), otype V)
5void ?{}(tree(K, V) &t, K key, V value){
6  (t.key) { key };
7  (t.value) { value };
8  t.parent = NULL;
9  t.left = NULL;
10  t.right = NULL;
11  t.balance = 0;
12}
13
14forall(otype K, otype V)
15void ^?{}(tree(K, V) & t){
16  delete(t.left);
17  delete(t.right);
18  ^(t.key){};
19  ^(t.value){};
20}
21
22forall(otype K | Comparable(K), otype V)
23tree(K, V) * create(K key, V value) {
24  // infinite loop trying to resolve ... t = malloc();
25  tree(K, V) * t = malloc(sizeof(tree(K,V)));
26  (*t){ key, value };
27  return t;
28}
29
30// // Helper function to print trees
31// forall(otype K | Comparable(K), otype V)
32// void printTree(tree * t, int level){
33//   if (empty(t)){
34//     return;
35//   }
36
37//   printTree(t->left, level+1);
38//   printf("key: %d, value: %s, level: %d\n", t->key, t->value, level);
39//   printTree(t->right, level+1);
40// }
41
42// // inorder traversal of t
43// // prints each key, followed by the value
44// forall(otype K | Comparable(K), otype V)
45// void printTree(tree(K, V) * t){
46//     printTree(t, 0);
47// }
Note: See TracBrowser for help on using the repository browser.