@@ -24,7 +24,7 @@ public AVLTree() {
24
24
/**
25
25
* 使用一个排好序的列表来创建AVL树
26
26
*
27
- * @param arr
27
+ * @param arr 排好序的数组
28
28
*/
29
29
public AVLTree (T [] arr ) {
30
30
Preconditions .checkNotNull (arr );
@@ -243,6 +243,7 @@ private boolean getNodePathCore(Node start, T ele, Stack<Node> path_stack) {
243
243
}
244
244
245
245
246
+ @ SuppressWarnings ("unused" )
246
247
private Vector <LinkedList <Node >> createLevelLinkedList () {
247
248
Vector <LinkedList <Node >> result = new Vector <>();
248
249
LinkedList <Node > current = new LinkedList <>();
@@ -275,7 +276,7 @@ private Vector<LinkedList<Node>> createLevelLinkedList() {
275
276
* @param tree
276
277
* @return
277
278
*/
278
- public boolean isSubTree (AVLTree tree ) {
279
+ public boolean isSubTree (AVLTree < T > tree ) {
279
280
Preconditions .checkNotNull (tree );
280
281
if (_head .getValue () == null && tree ._head .getValue () == null ) {
281
282
return true ;
@@ -400,7 +401,7 @@ public Iterator<T> postIterator() {
400
401
* 2,左子树不存在,那么直接把右子树移动到父节点位置
401
402
* 3,左右子树都存在,那么取出后继节点,后继节点肯定满足上面的1,2种条件。
402
403
*
403
- * @param ele
404
+ * @param ele 要删除的元素
404
405
*/
405
406
@ Override
406
407
public void delete (T ele ) {
@@ -654,12 +655,6 @@ public String toString() {
654
655
final StringBuilder sb = new StringBuilder ("Node{" );
655
656
sb .append ("height=" ).append (height );
656
657
sb .append (", value=" ).append (value );
657
- // if (left != null) {
658
- // sb.append(",\n\t left=").append(left);
659
- // }
660
- // if (right != null) {
661
- // sb.append(",\n\t right=").append(right);
662
- // }
663
658
sb .append ('}' );
664
659
return sb .toString ();
665
660
}
@@ -669,12 +664,12 @@ public boolean equals(Object o) {
669
664
if (this == o ) return true ;
670
665
if (o == null || getClass () != o .getClass ()) return false ;
671
666
667
+ @ SuppressWarnings ("unchecked" )
672
668
Node node = (Node ) o ;
673
669
674
670
if (height != node .height ) return false ;
675
- if (! value .equals (node .value )) return false ;
671
+ return value .equals (node .value );
676
672
677
- return true ;
678
673
}
679
674
680
675
@ Override
0 commit comments