Changeset fd54fef for tests/avltree/avl.h
- Timestamp:
- Jan 19, 2021, 8:44:29 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- dafbde8
- Parents:
- 2f47ea4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/avltree/avl.h
r2f47ea4 rfd54fef 9 9 // #include <lib.h> 10 10 11 trait Comparable( otypeT) {11 trait Comparable(T) { 12 12 int ?<?(T, T); 13 13 }; 14 14 15 forall( otypeT | Comparable(T))15 forall(T | Comparable(T)) 16 16 int ?==?(T t1, T t2); 17 17 18 forall( otypeT | Comparable(T))18 forall(T | Comparable(T)) 19 19 int ?>?(T t1, T t2); 20 20 … … 41 41 42 42 // temporary: need forward decl to get around typedef problem 43 forall( otype K | Comparable(K), otypeV)43 forall(K | Comparable(K), V) 44 44 struct tree; 45 45 46 forall( otype K | Comparable(K), otypeV)46 forall(K | Comparable(K), V) 47 47 struct tree { 48 48 K key; … … 54 54 }; 55 55 56 forall( otype K | Comparable(K), otypeV)56 forall(K | Comparable(K), V) 57 57 void ?{}(tree(K, V) &t, K key, V value); 58 58 59 forall( otype K | Comparable(K), otypeV)59 forall(K | Comparable(K), V) 60 60 void ^?{}(tree(K, V) & t); 61 61 62 forall( otype K | Comparable(K), otypeV)62 forall(K | Comparable(K), V) 63 63 tree(K, V) * create(K key, V value); 64 64 65 forall( otype K | Comparable(K), otypeV)65 forall(K | Comparable(K), V) 66 66 V * find(tree(K, V) * t, K key); 67 67 68 forall( otype K | Comparable(K), otypeV)68 forall(K | Comparable(K), V) 69 69 int empty(tree(K, V) * t); 70 70 71 71 // returns the root of the tree 72 forall( otype K | Comparable(K), otypeV)72 forall(K | Comparable(K), V) 73 73 int insert(tree(K, V) ** t, K key, V value); 74 74 75 forall( otype K | Comparable(K), otypeV)75 forall(K | Comparable(K), V) 76 76 int remove(tree(K, V) ** t, K key); 77 77 78 forall( otype K | Comparable(K), otypeV)78 forall(K | Comparable(K), V) 79 79 void copy(tree(K, V) * src, tree(K, V) ** ret); 80 80 81 forall( otype K | Comparable(K), otypeV)81 forall(K | Comparable(K), V) 82 82 void for_each(tree(K, V) * t, void (*func)(V)); 83 83
Note: See TracChangeset
for help on using the changeset viewer.