From 5962d43f2099e2bdfc095a2cb6e8b5145a971a28 Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Fri, 5 Jul 2019 12:38:31 +0530 Subject: [PATCH] Fix linter warnings --- .../java/net/abhinavsarkar/algorist/AVLTree.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/abhinavsarkar/algorist/AVLTree.java b/src/main/java/net/abhinavsarkar/algorist/AVLTree.java index 91e2077..2d44854 100644 --- a/src/main/java/net/abhinavsarkar/algorist/AVLTree.java +++ b/src/main/java/net/abhinavsarkar/algorist/AVLTree.java @@ -220,20 +220,16 @@ public class AVLTree,V> implements Iterable 1) { ValueNode l = this.left.toValueNode(); - if (l.balance() > 0) { // left-left case - return this.rotateRight(); - } else { // left-right case + if (l.balance() <= 0) { // left-right case this.left = l.rotateLeft(); - return this.rotateRight(); } + return this.rotateRight(); } else if (balance < -1) { ValueNode r = this.right.toValueNode(); if (r.balance() > 0) { // right-left case this.right = r.rotateRight(); - return this.rotateLeft(); - } else { // right-right case - return this.rotateLeft(); } + return this.rotateLeft(); } return this; } @@ -467,8 +463,8 @@ public class AVLTree,V> implements Iterable { - private K key; - private V val; + private final K key; + private final V val; public Entry(K key, V val) { this.key = key;