-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAVLNode.java
116 lines (103 loc) · 2.02 KB
/
AVLNode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* Node class used for implementing the AVL.
*
* DO NOT MODIFY THIS FILE!!
*
* @author CS 1332 TAs
* @version 1.0
*/
public class AVLNode<T extends Comparable<? super T>> {
private T data;
private AVLNode<T> left;
private AVLNode<T> right;
private int height;
private int balanceFactor;
/**
* Create an AVLNode with the given data.
*
* @param data The data stored in the new node.
*/
public AVLNode(T data) {
this.data = data;
}
/**
* Gets the data.
*
* @return The data.
*/
public T getData() {
return data;
}
/**
* Gets the left child.
*
* @return The left child.
*/
public AVLNode<T> getLeft() {
return left;
}
/**
* Gets the right child.
*
* @return The right child.
*/
public AVLNode<T> getRight() {
return right;
}
/**
* Gets the height.
*
* @return The height.
*/
public int getHeight() {
return height;
}
/**
* Gets the balance factor.
*
* @return The balance factor.
*/
public int getBalanceFactor() {
return balanceFactor;
}
/**
* Sets the data.
*
* @param data The new data.
*/
public void setData(T data) {
this.data = data;
}
/**
* Sets the left child.
*
* @param left The new left child.
*/
public void setLeft(AVLNode<T> left) {
this.left = left;
}
/**
* Sets the right child.
*
* @param right The new right child.
*/
public void setRight(AVLNode<T> right) {
this.right = right;
}
/**
* Sets the height.
*
* @param height The new height.
*/
public void setHeight(int height) {
this.height = height;
}
/**
* Sets the balance factor.
*
* @param balanceFactor The new balance factor.
*/
public void setBalanceFactor(int balanceFactor) {
this.balanceFactor = balanceFactor;
}
}