Section Header
  
  
    + name := AVL_TREE_NODE[E];
  
  
    - comment := "Auxiliary class to implement AVL_SET.";
	
  
 This a classic implementation of an AVL tree (balanced tree first designed 
  
 by Adelson-Velskii and Landis (hence A.V.L.), 1960)
Section Insert
  
  
    - parent_avl_constants:AVL_CONSTANTS := 
Section Public
  
  
    - out_in_tagged_out_memory <-
  
Section Public 
  
AVL_TREE_NODE, AVL_TREE
  
  
    + left:AVL_TREE_NODE[E];
  
    + right:AVL_TREE_NODE[E];
  
    + item:E;
  
    + balance:INTEGER;
  
         Balance factor; either `balanced' (the tree is balanced),
  
         `imbalanced_left' (the left branch is the longer) or
  
         `imbalanced_right' (the right branch is the longer)
  
    - count:INTEGER <-
  
  
    - height:INTEGER <-
  
  
    - map_in map:COLLECTION[AVL_TREE_NODE[E]] <-
  
  
    - has e:E :BOOLEAN <-
  
         Is element `e' in the tree?
  
  
    - fast_has e:E :BOOLEAN <-
  
         Is element `e' in the tree?
  
  
    - at e:E :AVL_TREE_NODE[E] <-
  
         Is element `e' in the tree?
  
  
    - set_item i:E <-
  
  
    - set_left l:AVL_TREE_NODE[E] <-
  
  
    - set_right r:AVL_TREE_NODE[E] <-
  
  
    - set_balance b:INTEGER <-
  
Section AVL_TREE, AVL_DICTIONARY, AVL_SET
  
  
  
 Rotations:
  
  
  
    - rotate_right:AVL_TREE_NODE[E] <-
  
         Proceeds to some reorganisation and returns the upper node.
  
  
    - rotate_left:AVL_TREE_NODE[E] <-
  
         Proceeds to some reorganisation and returns the upper node.