Changes in tests/avltree/avl-private.cfa [fd54fef:107b01a]
- File:
-
- 1 edited
-
tests/avltree/avl-private.cfa (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/avltree/avl-private.cfa
rfd54fef r107b01a 11 11 // an AVL tree's height is easy to compute 12 12 // just follow path with the larger balance 13 forall( K | Comparable(K),V)13 forall(otype K | Comparable(K), otype V) 14 14 int height(tree(K, V) * t){ 15 15 int helper(tree(K, V) * t, int ht){ … … 27 27 } 28 28 29 forall( K | Comparable(K),V)29 forall(otype K | Comparable(K), otype V) 30 30 int calcBalance(tree(K, V) * t){ 31 31 int l = height(t->left); … … 36 36 37 37 // re-establish the link between parent and child 38 forall( K | Comparable(K),V)38 forall(otype K | Comparable(K), otype V) 39 39 void relinkToParent(tree(K, V) * t){ 40 40 tree(K, V) * parent = t->parent; // FIX ME!! … … 49 49 50 50 // rotate left from t 51 forall( K | Comparable(K),V)51 forall(otype K | Comparable(K), otype V) 52 52 tree(K, V) * rotateLeft(tree(K, V) * t){ 53 53 tree(K, V) * newRoot = t->right; … … 68 68 69 69 // rotate right from t 70 forall( K | Comparable(K),V)70 forall(otype K | Comparable(K), otype V) 71 71 tree(K, V) * rotateRight(tree(K, V) * t){ 72 72 tree(K, V) * newRoot = t->left; … … 87 87 88 88 // balances a node that has balance factor -2 or 2 89 forall( K | Comparable(K),V)89 forall(otype K | Comparable(K), otype V) 90 90 tree(K, V) * fix(tree(K, V) * t){ 91 91 // ensure that t's balance factor is one of … … 113 113 114 114 // attempt to fix the tree, if necessary 115 forall( K | Comparable(K),V)115 forall(otype K | Comparable(K), otype V) 116 116 tree(K, V) * tryFix(tree(K, V) * t){ 117 117 int b = calcBalance(t); … … 126 126 127 127 // sets parent field of c to be p 128 forall( K | Comparable(K),V)128 forall(otype K | Comparable(K), otype V) 129 129 void setParent(tree(K, V) * c, tree(K, V) * p){ 130 130 if (! empty(c)){
Note:
See TracChangeset
for help on using the changeset viewer.