0
|
1 package datastructures;
|
|
2
|
|
3
|
|
4 // Basic node stored in AVL trees
|
|
5 // Note that this class is not accessible outside
|
|
6 // of package DataStructures
|
|
7
|
|
8 class AVLNode
|
|
9 {
|
|
10 // Constructors
|
|
11 @SuppressWarnings("unchecked")
|
|
12 AVLNode( Comparable theElement )
|
|
13 {
|
|
14 this( theElement, null, null );
|
|
15 }
|
|
16
|
|
17 @SuppressWarnings("unchecked")
|
|
18 AVLNode( Comparable theElement, AVLNode lt, AVLNode rt )
|
|
19 {
|
|
20 element = theElement;
|
|
21 left = lt;
|
|
22 right = rt;
|
|
23 height = 0;
|
|
24 }
|
|
25
|
|
26 // Friendly data; accessible by other package routines
|
|
27 @SuppressWarnings("unchecked")
|
|
28 Comparable element; // The data in the node
|
|
29 AVLNode left; // Left child
|
|
30 AVLNode right; // Right child
|
|
31 int height; // Height
|
|
32 }
|