Changeset d3e4d6c for src/tests/avltree
- Timestamp:
- Aug 23, 2017, 6:22:07 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
- Children:
- 87e08e24, cb811ac
- Parents:
- 9f07232 (diff), bd37119 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/tests/avltree
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/avltree/avl.h
r9f07232 rd3e4d6c 21 21 // xxx - unbound type variable problems when trying to use new instead of create 22 22 // forall( otype T, ttype Params | { void ?{}(T *, Params); } ) T * new( Params p ); 23 24 forall(dtype T | { void ^?{}(T *); })25 void delete(T * x);26 23 27 24 // To-do: properly use height or balance factor … … 58 55 59 56 forall(otype K | Comparable(K), otype V) 60 void ?{}(tree(K, V) *t, K key, V value);57 void ?{}(tree(K, V) &t, K key, V value); 61 58 62 59 forall(otype K, otype V) 63 void ^?{}(tree(K, V) *t);60 void ^?{}(tree(K, V) & t); 64 61 65 62 forall(otype K | Comparable(K), otype V) -
src/tests/avltree/avl1.c
r9f07232 rd3e4d6c 1 1 #include "avl.h" 2 2 // #include "cwrap.h" 3 #include <stdlib> 3 4 4 5 forall(otype K | Comparable(K), otype V) 5 void ?{}(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;6 void ?{}(tree(K, V) &t, K key, V value){ 7 (t.key) { key }; 8 (t.value) { value }; 9 t.parent = NULL; 10 t.left = NULL; 11 t.right = NULL; 12 t.balance = 0; 12 13 } 13 14 14 15 forall(otype K, otype V) 15 void ^?{}(tree(K, V) *t){16 delete(t ->left);17 delete(t ->right);18 ^( &t->key){};19 ^( &t->value){};16 void ^?{}(tree(K, V) & t){ 17 delete(t.left); 18 delete(t.right); 19 ^(t.key){}; 20 ^(t.value){}; 20 21 } 21 22 … … 24 25 // infinite loop trying to resolve ... t = malloc(); 25 26 tree(K, V) * t = malloc(sizeof(tree(K,V))); 26 t{ key, value };27 (*t){ key, value }; 27 28 return t; 28 29 } -
src/tests/avltree/avl3.c
r9f07232 rd3e4d6c 1 1 #include "avl.h" 2 2 #include "avl-private.h" 3 #include <stdlib> 3 4 4 5 // from stdlib … … 32 33 t->left = NULL; 33 34 t->right = NULL; 34 delete SingleNode(t);35 delete(t); 35 36 } 36 37 -
src/tests/avltree/avl_test.c
r9f07232 rd3e4d6c 1 1 #include "avl.h" 2 2 #include "avl-private.h" 3 #include <stdlib> 3 4 4 5 extern "C" {
Note:
See TracChangeset
for help on using the changeset viewer.