Ranides Atterwim 10 лет назад
Родитель
Сommit
fec049cc47

+ 8 - 27
assira/src/main/java/net/ranides/assira/collection/sets/AVLTreeSet.java

@@ -175,7 +175,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
      * @return the corresponding entry, or <code>null</code> if no entry with
      * the given key exists.
      */
-    private Node<K> findEntry(K value) {
+    final Node<K> findNode(K value) {
         Node<K> entry = tree;
         int cmp;
         while (entry != null && (cmp = compare(value, entry.key)) != 0) {
@@ -192,7 +192,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
      * given key, if it present; otherwise, it will be either the smallest
      * greater key or the greatest smaller key.
      */
-    final Node<K> locateEntry(K value) {
+    final Node<K> locateNode(K value) {
         Node<K> current = tree, last = tree;
         int cmp = 0;
         while (current != null && (cmp = compare(value, current.key)) != 0) {
@@ -663,7 +663,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
     @SuppressWarnings("unchecked")
     @Override
     public boolean contains(Object value) {
-        return findEntry((K) value) != null;
+        return findNode((K) value) != null;
     }
 
     @Override
@@ -681,7 +681,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
      *  <P>Note that since the class is recursive, it can be considered
      * equivalently a tree.
      */
-    protected static final class Node<K> {
+    private static final class Node<K> {
 
         /**
          * If the bit in this mask is true, {@link #right} points end a successor.
@@ -899,25 +899,6 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             return prev;
         }
 
-        @Override
-        public boolean equals(Object object) {
-            if (!(object instanceof Node)) {
-                return false;
-            }
-            Node<?> node = (Node<?>) object;
-            return CompareUtils.equals(key, node.key);
-        }
-
-        @Override
-        public int hashCode() {
-            return ((key) == null ? 0 : (key).hashCode());
-        }
-
-        @Override
-        public String toString() {
-            return String.valueOf(key);
-        }
-        
     }
     
     @Override
@@ -982,7 +963,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
         }
 
         TreeIterator(K value) {
-            if ((next = locateEntry(value)) != null) {
+            if ((next = locateNode(value)) != null) {
                 if (compare(next.key, value) <= 0) {
                     prev = next;
                     next = next.next();
@@ -1117,7 +1098,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             if (bottom) {
                 entry = firstEntry;
             } else {
-                entry = locateEntry(begin);
+                entry = locateNode(begin);
                 // If we find either the start or something greater we're OK.
                 if (compare(entry.key, begin) < 0) {
                     entry = entry.next();
@@ -1145,7 +1126,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             if (top) {
                 entry = lastEntry;
             } else {
-                entry = locateEntry(end);
+                entry = locateNode(end);
                 // If we find something smaller than the end we're OK.
                 if (compare(entry.key, end) >= 0) {
                     entry = entry.prev();
@@ -1190,7 +1171,7 @@ public class AVLTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                     } else if (!top && compare(key, (prev = lastEntry()).key) >= 0) {
                         next = null;
                     } else {
-                        next = locateEntry(key);
+                        next = locateNode(key);
                         if (compare(next.key, key) <= 0) {
                             prev = next;
                             next = next.next();

+ 70 - 89
assira/src/main/java/net/ranides/assira/collection/sets/IntAVLTreeSet.java

@@ -39,7 +39,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
     /**
      * A reference end the root entry.
      */
-    protected transient Entry tree;
+    protected transient Node tree;
     /**
      * Number of elements in this set.
      */
@@ -47,11 +47,11 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
     /**
      * The entry of the first element of this set.
      */
-    protected transient Entry firstEntry;
+    protected transient Node firstEntry;
     /**
      * The entry of the last element of this set.
      */
-    protected transient Entry lastEntry;
+    protected transient Node lastEntry;
     /**
      * This vector remembers the path followed during the current insertion. It
      * suffices for about 2<sup>32</sup> entries.
@@ -210,8 +210,8 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
      * @return the corresponding entry, or <code>null</code> if no entry with
      * the given key exists.
      */
-    private Entry findKey(int key) {
-        Entry entry = tree;
+    final Node findNode(int key) {
+        Node entry = tree;
         int cmp;
         while (entry != null && (cmp = compare(key, entry.key)) != 0) {
             entry = cmp < 0 ? entry.left() : entry.right();
@@ -227,8 +227,9 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
      * given key, if it present; otherwise, it will be either the smallest
      * greater key or the greatest smaller key.
      */
-    final Entry locateKey(int key) {
-        Entry entry = tree, last = tree;
+    final Node locateNode(int key) {
+        Node entry = tree;
+		Node last = tree;
         int cmp = 0;
         while (entry != null && (cmp = compare(key, entry.key)) != 0) {
             last = entry;
@@ -242,9 +243,9 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
     public final boolean add(int value) {
         if (tree == null) { // The case of the empty tree is treated separately.
             count++;
-            tree = lastEntry = firstEntry = new Entry(value);
+            tree = lastEntry = firstEntry = new Node(value);
         } else {
-            Entry pnode = tree, qnode = null, ynode = tree, znode = null, enode = null, wnode;
+            Node pnode = tree, qnode = null, ynode = tree, znode = null, enode = null, wnode;
             int cmp, i = 0;
             while (true) {
                 if ((cmp = compare(value, pnode.key)) == 0) {
@@ -258,7 +259,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 if (dirPath[ i++] = cmp > 0) {
                     if (pnode.succ()) {
                         count++;
-                        enode = new Entry(value);
+                        enode = new Node(value);
                         if (pnode.right == null) {
                             lastEntry = enode;
                         }
@@ -272,7 +273,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 } else {
                     if (pnode.pred()) {
                         count++;
-                        enode = new Entry(value);
+                        enode = new Node(value);
                         if (pnode.left == null) {
                             firstEntry = enode;
                         }
@@ -296,7 +297,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 pnode = dirPath[ i++] ? pnode.right : pnode.left;
             }
             if (ynode.balance() == -2) {
-                Entry xnode = ynode.left;
+                Node xnode = ynode.left;
                 if (xnode.balance() == -1) {
                     wnode = xnode;
                     if (xnode.succ()) {
@@ -336,7 +337,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                     }
                 }
             } else if (ynode.balance() == +2) {
-                Entry xnode = ynode.right;
+                Node xnode = ynode.right;
                 if (xnode.balance() == 1) {
                     wnode = xnode;
                     if (xnode.pred()) {
@@ -397,11 +398,12 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
      * @param entry a node of the tree.
      * @return the parent of the given node, or <code>null</code> for the root.
      */
-    private Entry parent(Entry entry) {
+    private Node parent(Node entry) {
         if (entry == tree) { //NOPMD
             return null;
         }
-        Entry xnode, ynode, pnode;
+		Node xnode;
+        Node ynode, pnode;
         xnode = ynode = entry;
         while (true) {
             if (ynode.succ()) {
@@ -424,22 +426,22 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
         }
     }
 
-    private static boolean hasR(Entry pnode, Entry entry) {
+    private static boolean hasR(Node pnode, Node entry) {
         return pnode == null || pnode.right != entry;
     }
 
-    private static boolean hasL(Entry pnode, Entry entry) {
+    private static boolean hasL(Node pnode, Node entry) {
         return pnode == null || pnode.left != entry;
     }
 
-    private static Entry movR(Entry ynode) {
+    private static Node movR(Node ynode) {
         while (!ynode.succ()) {
             ynode = ynode.right;
         }
         return ynode;
     }
 
-    private static Entry movL(Entry xnode) {
+    private static Node movL(Node xnode) {
         while (!xnode.pred()) {
             xnode = xnode.left;
         }
@@ -453,7 +455,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
             return false;
         }
         int cmp;
-        Entry pnode = tree, qnode = null;
+        Node pnode = tree, qnode = null;
         boolean dir = false;
         final int kk = value;
         while (true) {
@@ -501,7 +503,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 }
             }
         } else {
-            Entry rnode = pnode.right;
+            Node rnode = pnode.right;
             if (rnode.pred()) {
                 rnode.left = pnode.left;
                 rnode.pred(pnode.pred());
@@ -521,7 +523,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 qnode = rnode;
                 dir = true;
             } else {
-                Entry snode;
+                Node snode;
                 while (true) {
                     snode = rnode.left;
                     if (snode.pred()) {
@@ -555,7 +557,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 dir = false;
             }
         }
-        Entry ynode;
+        Node ynode;
         while (qnode != null) {
             ynode = qnode;
             qnode = parent(ynode);
@@ -565,10 +567,10 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 if (ynode.balance() == 1) {
                     break;
                 } else if (ynode.balance() == 2) {
-                    Entry xnode = ynode.right;
+                    Node xnode = ynode.right;
                     assert xnode != null;
                     if (xnode.balance() == -1) {
-                        Entry wnode;
+                        Node wnode;
                         assert xnode.balance() == -1;
                         wnode = xnode.left;
                         xnode.left = wnode.right;
@@ -639,10 +641,10 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                 if (ynode.balance() == -1) {
                     break;
                 } else if (ynode.balance() == -2) {
-                    Entry xnode = ynode.left;
+                    Node xnode = ynode.left;
                     assert xnode != null;
                     if (xnode.balance() == 1) {
-                        Entry wnode;
+                        Node wnode;
                         assert xnode.balance() == 1;
                         wnode = xnode.right;
                         xnode.right = wnode.left;
@@ -716,7 +718,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
     @SuppressWarnings("unchecked")
     @Override
     public boolean contains(int key) {
-        return findKey(key) != null;
+        return findNode(key) != null;
     }
 
     @Override
@@ -786,9 +788,9 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
      * tree.
      */
     @SuppressWarnings("unchecked")
-    private Entry readTree(java.io.ObjectInputStream istream, int n, Entry pred, Entry succ) throws java.io.IOException, ClassNotFoundException {
+    private Node readTree(java.io.ObjectInputStream istream, int n, Node pred, Node succ) throws java.io.IOException, ClassNotFoundException {
         if (n == 1) {
-            final Entry top = new Entry(istream.readInt());
+            final Node top = new Node(istream.readInt());
             top.pred(pred);
             top.succ(succ);
             return top;
@@ -796,8 +798,8 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
         if (n == 2) {
             /* We handle separately this case so that recursion will
              *always* be on nonempty subtrees. */
-            final Entry top = new Entry(istream.readInt());
-            top.right(new Entry(istream.readInt()));
+            final Node top = new Node(istream.readInt());
+            top.right(new Node(istream.readInt()));
             top.right.pred(top);
             top.balance(1);
             top.pred(pred);
@@ -806,7 +808,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
         }
         // The right subtree is the largest one.
         final int rightN = n / 2, leftN = n - rightN - 1;
-        final Entry top = new Entry();
+        final Node top = new Node();
         top.left(readTree(istream, leftN, pred, top));
         top.key = istream.readInt();
         top.right(readTree(istream, rightN, top, succ));
@@ -821,7 +823,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
         allocatePaths();
         if (count != 0) {
             tree = readTree(istream, count, null, null);
-            Entry entry;
+            Node entry;
             entry = tree;
             while (entry.left() != null) {
                 entry = entry.left();
@@ -839,13 +841,13 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
 	/**
      * This class represent an entry in a tree set.
      *
-     * <P>We use the only "metadata", i.e., {@link Entry#info}, end store
+     * <P>We use the only "metadata", i.e., {@link Node#info}, end store
      * information about balance, predecessor status and successor status.
      *
      * <P>Note that since the class is recursive, it can be considered
      * equivalently a tree.
      */
-    protected static final class Entry {
+    private static final class Node {
 
         /**
          * If the bit in this mask is true, {@link #right} points end a successor.
@@ -864,22 +866,20 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * The key of this entry.
          */
         int key;
-        /**
-         * The pointers to the left and right subtrees.
-         */
-        Entry left,
 
         /**
-         * The pointers end the left and right subtrees.
-         */
-        right;
+		 * The pointers to the left and right subtrees.
+		 */
+		Node left;
+
+		Node right;
         /**
          * This integers holds different information in different bits (see
          * {@link #SUCC_MASK}, {@link #PRED_MASK} and {@link #BALANCE_MASK}).
          */
         int info;
 
-        Entry() {
+        Node() {
         }
 
         /**
@@ -887,7 +887,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param k a key.
          */
-        Entry(int k) {
+        Node(int k) {
             this.key = k;
             info = SUCC_MASK | PRED_MASK;
         }
@@ -898,7 +898,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the left subtree (<code>null</code> if the left subtree is
          * empty).
          */
-        Entry left() {
+        Node left() {
             return (info & PRED_MASK) != 0 ? null : left;
         }
 
@@ -908,7 +908,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the right subtree (<code>null</code> if the right subtree is
          * empty).
          */
-        Entry right() {
+        Node right() {
             return (info & SUCC_MASK) != 0 ? null : right;
         }
 
@@ -963,7 +963,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param pred the predecessr.
          */
-        void pred(Entry pred) {
+        void pred(Node pred) {
             info |= PRED_MASK;
             left = pred;
         }
@@ -973,7 +973,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param succ the successor.
          */
-        void succ(Entry succ) {
+        void succ(Node succ) {
             info |= SUCC_MASK;
             right = succ;
         }
@@ -983,7 +983,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param left the new left subtree.
          */
-        void left(Entry left) {
+        void left(Node left) {
             info &= ~PRED_MASK;
             this.left = left;
         }
@@ -993,7 +993,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param right the new right subtree.
          */
-        void right(Entry right) {
+        void right(Node right) {
             info &= ~SUCC_MASK;
             this.right = right;
         }
@@ -1037,8 +1037,8 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the next entry (<code>null</code>) if this is the last
          * entry).
          */
-        Entry next() {
-            Entry next = this.right;
+        Node next() {
+            Node next = this.right;
             if ((info & SUCC_MASK) == 0) {
                 while ((next.info & PRED_MASK) == 0) {
                     next = next.left;
@@ -1053,8 +1053,8 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the previous entry (<code>null</code>) if this is the first
          * entry).
          */
-        Entry prev() {
-            Entry prev = this.left;
+        Node prev() {
+            Node prev = this.left;
             if ((info & PRED_MASK) == 0) {
                 while ((prev.info & SUCC_MASK) == 0) {
                     prev = prev.right;
@@ -1063,25 +1063,6 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
             return prev;
         }
 
-        @Override
-        public boolean equals(Object object) {
-            if (!(object instanceof Entry)) {
-                return false;
-            }
-            Entry entry = (Entry) object;
-            return ((key) == (entry.key));
-        }
-
-        @Override
-        public int hashCode() {
-            return key;
-        }
-
-        @Override
-        public String toString() {
-            return String.valueOf(key);
-        }
-
     }
 
     protected class TreeIterator implements IntListIterator {
@@ -1091,18 +1072,18 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * {@link java.util.ListIterator#previous()} (or
          * <code>null</code> if no previous entry exists).
          */
-        Entry prev;
+        Node prev;
         /**
          * The entry that will be returned by the next call end
          * {@link java.util.ListIterator#next()} (or
          * <code>null</code> if no next entry exists).
          */
-        Entry next;
+        Node next;
         /**
          * The last entry that was returned (or
          * <code>null</code> if we did not iterate or used {@link #remove()}).
          */
-        Entry curr;
+        Node curr;
         /**
          * The current index (in the sense of a {@link java.util.ListIterator}).
          * Note that this value is not meaningful when this {@link TreeIterator}
@@ -1115,7 +1096,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
         }
 
         TreeIterator(int k) {
-            if ((next = locateKey(k)) != null) {
+            if ((next = locateNode(k)) != null) {
                 if (compare(next.key, k) <= 0) {
                     prev = next;
                     next = next.next();
@@ -1139,7 +1120,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
             next = next.next();
         }
 
-        Entry nextEntry() {
+        Node nextEntry() {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
@@ -1163,7 +1144,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
             prev = prev.prev();
         }
 
-        Entry previousEntry() {
+        Node previousEntry() {
             if (!hasPrevious()) {
                 throw new NoSuchElementException();
             }
@@ -1226,16 +1207,16 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the first entry of this subset, or <code>null</code> if the
          * subset is empty.
          */
-        public IntAVLTreeSet.Entry firstEntry() {
+        public IntAVLTreeSet.Node firstEntry() {
             if (tree == null) {
                 return null;
             }
             // If this subset goes end -infinity, we return the main set first entry; otherwise, we locate the start of the set.
-            IntAVLTreeSet.Entry entry;
+            IntAVLTreeSet.Node entry;
             if (bottom) {
                 entry = firstEntry;
             } else {
-                entry = locateKey(begin);
+                entry = locateNode(begin);
                 // If we find either the start or something greater we're OK.
                 if (compare(entry.key, begin) < 0) {
                     entry = entry.next();
@@ -1254,16 +1235,16 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the last entry of this subset, or <code>null</code> if the
          * subset is empty.
          */
-        public IntAVLTreeSet.Entry lastEntry() {
+        public IntAVLTreeSet.Node lastEntry() {
             if (tree == null) {
                 return null;
             }
             // If this subset goes end infinity, we return the main set last entry; otherwise, we locate the end of the set.
-            IntAVLTreeSet.Entry entry;
+            IntAVLTreeSet.Node entry;
             if (top) {
                 entry = lastEntry;
             } else {
-                entry = locateKey(end);
+                entry = locateNode(end);
                 // If we find something smaller than the end we're OK.
                 if (compare(entry.key, end) >= 0) {
                     entry = entry.prev();
@@ -1278,7 +1259,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
 
         @Override
         public int firstInt() {
-            IntAVLTreeSet.Entry entry = firstEntry();
+            IntAVLTreeSet.Node entry = firstEntry();
             if (entry == null) {
                 throw new NoSuchElementException();
             }
@@ -1287,7 +1268,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
 
         @Override
         public int lastInt() {
-            IntAVLTreeSet.Entry entry = lastEntry();
+            IntAVLTreeSet.Node entry = lastEntry();
             if (entry == null) {
                 throw new NoSuchElementException();
             }
@@ -1319,7 +1300,7 @@ public class IntAVLTreeSet extends AIntSortedSet implements java.io.Serializable
                     } else if (!top && compare(k, (prev = lastEntry()).key) >= 0) {
                         next = null;
                     } else {
-                        next = locateKey(k);
+                        next = locateNode(k);
                         if (compare(next.key, k) <= 0) {
                             prev = next;
                             next = next.next();

+ 68 - 83
assira/src/main/java/net/ranides/assira/collection/sets/IntRBTreeSet.java

@@ -34,7 +34,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
     /**
      * A reference to the root entry.
      */
-    protected transient Entry tree;
+    protected transient Node tree;
     /**
      * Number of elements in this set.
      */
@@ -42,11 +42,11 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
     /**
      * The entry of the first element of this set.
      */
-    protected transient Entry firstEntry;
+    protected transient Node firstEntry;
     /**
      * The entry of the last element of this set.
      */
-    protected transient Entry lastEntry;
+    protected transient Node lastEntry;
     
     /**
      * This vector remembers the path and the direction followed during the
@@ -54,7 +54,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
      */
     protected transient boolean dirPath[];
     
-    protected transient Entry nodePath[];
+    protected transient Node nodePath[];
 
     /**
      * Creates a new empty tree set.
@@ -199,7 +199,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
 	@SuppressWarnings("unchecked")
     private void allocatePaths() {
         dirPath = new boolean[64];
-        nodePath = new Entry[64];
+        nodePath = new Node[64];
     }
     
     /**
@@ -210,8 +210,8 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
      * @return the corresponding entry, or <code>null</code> if no entry with
      * the given key exists.
      */
-    final Entry findKey(int key) {
-        Entry entry = tree;
+    final Node findNode(int key) {
+        Node entry = tree;
         int cmp;
         while (entry != null && (cmp = compare(key, entry.key)) != 0) {
             entry = cmp < 0 ? entry.left() : entry.right();
@@ -227,8 +227,9 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
      * given key, if it present; otherwise, it will be either the smallest
      * greater key or the greatest smaller key.
      */
-    final Entry locateKey(int key) {
-        Entry entry = tree, last = tree;
+    final Node locateNode(int key) {
+        Node entry = tree;
+		Node last = tree;
         int cmp = 0;
         while (entry != null && (cmp = compare(key, entry.key)) != 0) {
             last = entry;
@@ -243,9 +244,9 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
         int maxDepth = 0;
         if (tree == null) { // The case of the empty tree is treated separately.
             count++;
-            tree = lastEntry = firstEntry = new Entry(key);
+            tree = lastEntry = firstEntry = new Node(key);
         } else {
-            Entry pnode = tree, enode;
+            Node pnode = tree, enode;
             int cmp, i = 0;
             while (true) {
                 if ((cmp = compare(key, pnode.key)) == 0) {
@@ -259,7 +260,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                 if (dirPath[ i++] = cmp > 0) {
                     if (pnode.succ()) {
                         count++;
-                        enode = new Entry(key);
+                        enode = new Node(key);
                         if (pnode.right == null) {
                             lastEntry = enode;
                         }
@@ -272,7 +273,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                 } else {
                     if (pnode.pred()) {
                         count++;
-                        enode = new Entry(key);
+                        enode = new Node(key);
                         if (pnode.left == null) {
                             firstEntry = enode;
                         }
@@ -287,14 +288,14 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
             maxDepth = i--;
             while (i > 0 && !nodePath[ i].black()) {
                 if (!dirPath[ i - 1]) {
-                    Entry ynode = nodePath[ i - 1].right;
+                    Node ynode = nodePath[ i - 1].right;
                     if (!nodePath[ i - 1].succ() && !ynode.black()) {
                         nodePath[ i].black(true);
                         ynode.black(true);
                         nodePath[ i - 1].black(false);
                         i -= 2;
                     } else {
-                        Entry xnode;
+                        Node xnode;
                         if (!dirPath[ i]) {
                             ynode = nodePath[ i];
                         } else {
@@ -329,14 +330,14 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                         break;
                     }
                 } else {
-                    Entry ynode = nodePath[ i - 1].left;
+                    Node ynode = nodePath[ i - 1].left;
                     if (!nodePath[ i - 1].pred() && !ynode.black()) {
                         nodePath[ i].black(true);
                         ynode.black(true);
                         nodePath[ i - 1].black(false);
                         i -= 2;
                     } else {
-                        Entry xnode;
+                        Node xnode;
                         if (dirPath[ i]) {
                             ynode = nodePath[ i];
                         } else {
@@ -387,7 +388,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
         if (tree == null) {
             return false;
         }
-        Entry pnode = tree;
+        Node pnode = tree;
         int cmp;
         int i = 0;
         final int kk = key;
@@ -446,7 +447,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
             }
         } else {
             boolean color;
-            Entry rnode = pnode.right;
+            Node rnode = pnode.right;
             if (rnode.pred()) {
                 rnode.left = pnode.left;
                 rnode.pred(pnode.pred());
@@ -468,7 +469,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                 dirPath[ i] = true;
                 nodePath[ i++] = rnode;
             } else {
-                Entry snode;
+                Node snode;
                 int j = i++;
                 while (true) {
                     dirPath[ i] = false;
@@ -511,14 +512,14 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
             for (; i > 0; i--) {
                 if (dirPath[ i - 1] && !nodePath[ i - 1].succ()
                         || !dirPath[ i - 1] && !nodePath[ i - 1].pred()) {
-                    Entry xnode = dirPath[ i - 1] ? nodePath[ i - 1].right : nodePath[ i - 1].left;
+                    Node xnode = dirPath[ i - 1] ? nodePath[ i - 1].right : nodePath[ i - 1].left;
                     if (!xnode.black()) {
                         xnode.black(true);
                         break;
                     }
                 }
                 if (!dirPath[ i - 1]) {
-                    Entry wnode = nodePath[ i - 1].right;
+                    Node wnode = nodePath[ i - 1].right;
                     if (!wnode.black()) {
                         wnode.black(true);
                         nodePath[ i - 1].black(false);
@@ -546,7 +547,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                         wnode.black(false);
                     } else {
                         if (wnode.succ() || wnode.right.black()) {
-                            Entry ynode = wnode.left;
+                            Node ynode = wnode.left;
                             ynode.black(true);
                             wnode.black(false);
                             wnode.left = ynode.right;
@@ -578,7 +579,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                         break;
                     }
                 } else {
-                    Entry wnode = nodePath[ i - 1].left;
+                    Node wnode = nodePath[ i - 1].left;
                     if (!wnode.black()) {
                         wnode.black(true);
                         nodePath[ i - 1].black(false);
@@ -606,7 +607,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                         wnode.black(false);
                     } else {
                         if (wnode.pred() || wnode.left.black()) {
-                            Entry ynode = wnode.right;
+                            Node ynode = wnode.right;
                             ynode.black(true);
                             wnode.black(false);
                             wnode.right = ynode.left;
@@ -654,7 +655,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
     @SuppressWarnings("unchecked")
     @Override
     public boolean contains(int k) {
-        return findKey(k) != null;
+        return findNode(k) != null;
     }
 
     @Override
@@ -724,9 +725,9 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
      * tree.
      */
     @SuppressWarnings("unchecked")
-    private Entry readTree(java.io.ObjectInputStream istream, int n, Entry pred, Entry succ) throws java.io.IOException, ClassNotFoundException {
+    private Node readTree(java.io.ObjectInputStream istream, int n, Node pred, Node succ) throws java.io.IOException, ClassNotFoundException {
         if (n == 1) {
-            final Entry top = new Entry(istream.readInt());
+            final Node top = new Node(istream.readInt());
             top.pred(pred);
             top.succ(succ);
             top.black(true);
@@ -735,9 +736,9 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
         if (n == 2) {
             /* We handle separately this case so that recursion will
              *always* be on nonempty subtrees. */
-            final Entry top = new Entry(istream.readInt());
+            final Node top = new Node(istream.readInt());
             top.black(true);
-            top.right(new Entry(istream.readInt()));
+            top.right(new Node(istream.readInt()));
             top.right.pred(top);
             top.pred(pred);
             top.right.succ(succ);
@@ -745,7 +746,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
         }
         // The right subtree is the largest one.
         final int rightN = n / 2, leftN = n - rightN - 1;
-        final Entry top = new Entry();
+        final Node top = new Node();
         top.left(readTree(istream, leftN, pred, top));
         top.key = istream.readInt();
         top.black(true);
@@ -761,7 +762,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
         allocatePaths();
         if (count != 0) {
             tree = readTree(istream, count, null, null);
-            Entry entry;
+            Node entry;
             entry = tree;
             while (entry.left() != null) {
                 entry = entry.left();
@@ -778,13 +779,13 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
 	/**
      * This class represent an entry in a tree set.
      *
-     * <P>We use the only "metadata", i.e., {@link Entry#info}, to store
+     * <P>We use the only "metadata", i.e., {@link Node#info}, to store
      * information about color, predecessor status and successor status.
      *
      * <P>Note that since the class is recursive, it can be considered
      * equivalently a tree.
      */
-    protected static final class Entry {
+    private static final class Node {
 
         /**
          * The the bit in this mask is true, the node is black.
@@ -804,17 +805,20 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * The key of this entry.
          */
         int key;
+
         /**
-         * The pointers to the left and right subtrees.
-         */
-        Entry left, right;
+		 * The pointers to the left and right subtrees.
+		 */
+		Node left;
+
+		Node right;
         /**
          * This integers holds different information in different bits (see
          * {@link #SUCC_MASK}, {@link #PRED_MASK} and {@link #BLACK_MASK}).
          */
         int info;
 
-        Entry() {
+        Node() {
         }
 
         /**
@@ -822,7 +826,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param k a key.
          */
-        Entry(int k) {
+        Node(int k) {
             this.key = k;
             info = SUCC_MASK | PRED_MASK;
         }
@@ -833,7 +837,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the left subtree (<code>null</code> if the left subtree is
          * empty).
          */
-        Entry left() {
+        Node left() {
             return (info & PRED_MASK) != 0 ? null : left;
         }
 
@@ -843,7 +847,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the right subtree (<code>null</code> if the right subtree is
          * empty).
          */
-        Entry right() {
+        Node right() {
             return (info & SUCC_MASK) != 0 ? null : right;
         }
 
@@ -898,7 +902,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param pred the predecessr.
          */
-        void pred(Entry pred) {
+        void pred(Node pred) {
             info |= PRED_MASK;
             left = pred;
         }
@@ -908,7 +912,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param succ the successor.
          */
-        void succ(Entry succ) {
+        void succ(Node succ) {
             info |= SUCC_MASK;
             right = succ;
         }
@@ -918,7 +922,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param left the new left subtree.
          */
-        void left(Entry left) {
+        void left(Node left) {
             info &= ~PRED_MASK;
             this.left = left;
         }
@@ -928,7 +932,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          *
          * @param right the new right subtree.
          */
-        void right(Entry right) {
+        void right(Node right) {
             info &= ~SUCC_MASK;
             this.right = right;
         }
@@ -962,8 +966,8 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the next entry (<code>null</code>) if this is the last
          * entry).
          */
-        Entry next() {
-            Entry next = this.right;
+        Node next() {
+            Node next = this.right;
             if ((info & SUCC_MASK) == 0) {
                 while ((next.info & PRED_MASK) == 0) {
                     next = next.left;
@@ -978,8 +982,8 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the previous entry (<code>null</code>) if this is the first
          * entry).
          */
-        Entry prev() {
-            Entry prev = this.left;
+        Node prev() {
+            Node prev = this.left;
             if ((info & PRED_MASK) == 0) {
                 while ((prev.info & SUCC_MASK) == 0) {
                     prev = prev.right;
@@ -988,25 +992,6 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
             return prev;
         }
 
-        @Override
-        public boolean equals(Object object) {
-            if (!(object instanceof Entry)) {
-                return false;
-            }
-            Entry entry = (Entry) object;
-            return key == entry.key;
-        }
-
-        @Override
-        public int hashCode() {
-            return key;
-        }
-
-        @Override
-        public String toString() {
-            return String.valueOf(key);
-        }
-
     }
 
     /**
@@ -1021,18 +1006,18 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * {@link java.util.ListIterator#previous()} (or
          * <code>null</code> if no previous entry exists).
          */
-        Entry prev;
+        Node prev;
         /**
          * The entry that will be returned by the next call to
          * {@link java.util.ListIterator#next()} (or
          * <code>null</code> if no next entry exists).
          */
-        Entry next;
+        Node next;
         /**
          * The last entry that was returned (or
          * <code>null</code> if we did not iterate or used {@link #remove()}).
          */
-        Entry curr;
+        Node curr;
         /**
          * The current index (in the sense of a {@link java.util.ListIterator}).
          * Note that this value is not meaningful when this iterator has been
@@ -1045,7 +1030,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
         }
 
         TreeIterator(int k) {
-            if ((next = locateKey(k)) != null) {
+            if ((next = locateNode(k)) != null) {
                 if (compare(next.key, k) <= 0) {
                     prev = next;
                     next = next.next();
@@ -1069,7 +1054,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
             next = next.next();
         }
 
-        Entry nextEntry() {
+        Node nextEntry() {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
@@ -1093,7 +1078,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
             prev = prev.prev();
         }
 
-        Entry previousEntry() {
+        Node previousEntry() {
             if (!hasPrevious()) {
                 throw new NoSuchElementException();
             }
@@ -1156,16 +1141,16 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the first entry of this subset, or <code>null</code> if the
          * subset is empty.
          */
-        public IntRBTreeSet.Entry firstEntry() {
+        public IntRBTreeSet.Node firstEntry() {
             if (tree == null) {
                 return null;
             }
             // If this subset goes to -infinity, we return the main set first entry; otherwise, we locate the start of the set.
-            IntRBTreeSet.Entry entry;
+            IntRBTreeSet.Node entry;
             if (bottom) {
                 entry = firstEntry;
             } else {
-                entry = locateKey(begin);
+                entry = locateNode(begin);
                 // If we find either the start or something greater we're OK.
                 if (compare(entry.key, begin) < 0) {
                     entry = entry.next();
@@ -1184,16 +1169,16 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
          * @return the last entry of this subset, or <code>null</code> if the
          * subset is empty.
          */
-        public IntRBTreeSet.Entry lastEntry() {
+        public IntRBTreeSet.Node lastEntry() {
             if (tree == null) {
                 return null;
             }
             // If this subset goes to infinity, we return the main set last entry; otherwise, we locate the end of the set.
-            IntRBTreeSet.Entry entry;
+            IntRBTreeSet.Node entry;
             if (top) {
                 entry = lastEntry;
             } else {
-                entry = locateKey(end);
+                entry = locateNode(end);
                 // If we find something smaller than the end we're OK.
                 if (compare(entry.key, end) >= 0) {
                     entry = entry.prev();
@@ -1208,7 +1193,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
 
         @Override
         public int firstInt() {
-            IntRBTreeSet.Entry entry = firstEntry();
+            IntRBTreeSet.Node entry = firstEntry();
             if (entry == null) {
                 throw new NoSuchElementException();
             }
@@ -1217,7 +1202,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
 
         @Override
         public int lastInt() {
-            IntRBTreeSet.Entry entry = lastEntry();
+            IntRBTreeSet.Node entry = lastEntry();
             if (entry == null) {
                 throw new NoSuchElementException();
             }
@@ -1238,7 +1223,7 @@ public class IntRBTreeSet extends AIntSortedSet implements java.io.Serializable
                     } else if (!top && compare(k, (prev = lastEntry()).key) >= 0) {
                         next = null;
                     } else {
-                        next = locateKey(k);
+                        next = locateNode(k);
                         if (compare(next.key, k) <= 0) {
                             prev = next;
                             next = next.next();

+ 71 - 92
assira/src/main/java/net/ranides/assira/collection/sets/RBTreeSet.java

@@ -31,7 +31,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
     /**
      * A reference end the root entry.
      */
-    protected transient Entry<K> tree;
+    protected transient Node<K> tree;
     /**
      * Number of elements in this set.
      */
@@ -39,11 +39,11 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
     /**
      * The entry of the first element of this set.
      */
-    protected transient Entry<K> firstEntry;
+    protected transient Node<K> firstEntry;
     /**
      * The entry of the last element of this set.
      */
-    protected transient Entry<K> lastEntry;
+    protected transient Node<K> lastEntry;
     
     /**
      * This vector remembers the path and the direction followed during the
@@ -51,7 +51,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
      */
     protected transient boolean dirPath[];
     
-    protected transient Entry<K> nodePath[];
+    protected transient Node<K> nodePath[];
 
     /**
      * Creates a new empty tree set.
@@ -162,6 +162,12 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             add(values[ i]);
         }
     }
+	
+	@SuppressWarnings("unchecked")
+    private void allocatePaths() {
+        dirPath = new boolean[64];
+        nodePath = new Node[64];
+    }
 
     /**
      * Returns the entry corresponding end the given key, if it is in the tree;
@@ -171,8 +177,8 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
      * @return the corresponding entry, or <code>null</code> if no entry with
      * the given key exists.
      */
-    final Entry<K> findKey(K key) {
-        Entry<K> entry = tree;
+    final Node<K> findNode(K key) {
+        Node<K> entry = tree;
         int cmp;
         while (entry != null && (cmp = compare(key, entry.key)) != 0) {
             entry = cmp < 0 ? entry.left() : entry.right();
@@ -188,8 +194,8 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
      * given key, if it present; otherwise, it will be either the smallest
      * greater key or the greatest smaller key.
      */
-    final Entry<K> locateKey(K key) {
-        Entry<K> entry = tree, last = tree;
+    final Node<K> locateNode(K key) {
+        Node<K> entry = tree, last = tree;
         int cmp = 0;
         while (entry != null && (cmp = compare(key, entry.key)) != 0) {
             last = entry;
@@ -198,21 +204,15 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
         return cmp == 0 ? entry : last;
     }
 
-    @SuppressWarnings("unchecked")
-    private void allocatePaths() {
-        dirPath = new boolean[64];
-        nodePath = new Entry[64];
-    }
-
 	@SuppressWarnings("PMD")
     @Override
     public final boolean add(K value) {
         int maxDepth = 0;
         if (tree == null) { // The case of the empty tree is treated separately.
             count++;
-            tree = lastEntry = firstEntry = new Entry<>(value);
+            tree = lastEntry = firstEntry = new Node<>(value);
         } else {
-            Entry<K> pnode = tree, enode;
+            Node<K> pnode = tree, enode;
             int cmp, i = 0;
             while (true) {
                 if ((cmp = compare(value, pnode.key)) == 0) {
@@ -226,7 +226,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                 if (dirPath[ i++] = cmp > 0) {
                     if (pnode.succ()) {
                         count++;
-                        enode = new Entry<>(value);
+                        enode = new Node<>(value);
                         if (pnode.right == null) {
                             lastEntry = enode;
                         }
@@ -239,7 +239,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                 } else {
                     if (pnode.pred()) {
                         count++;
-                        enode = new Entry<>(value);
+                        enode = new Node<>(value);
                         if (pnode.left == null) {
                             firstEntry = enode;
                         }
@@ -254,14 +254,14 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             maxDepth = i--;
             while (i > 0 && !nodePath[ i].black()) {
                 if (!dirPath[ i - 1]) {
-                    Entry<K> ynode = nodePath[ i - 1].right;
+                    Node<K> ynode = nodePath[ i - 1].right;
                     if (!nodePath[ i - 1].succ() && !ynode.black()) {
                         nodePath[ i].black(true);
                         ynode.black(true);
                         nodePath[ i - 1].black(false);
                         i -= 2;
                     } else {
-                        Entry<K> xnode;
+                        Node<K> xnode;
                         if (!dirPath[ i]) {
                             ynode = nodePath[ i];
                         } else {
@@ -296,14 +296,14 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                         break;
                     }
                 } else {
-                    Entry<K> ynode = nodePath[ i - 1].left;
+                    Node<K> ynode = nodePath[ i - 1].left;
                     if (!nodePath[ i - 1].pred() && !ynode.black()) {
                         nodePath[ i].black(true);
                         ynode.black(true);
                         nodePath[ i - 1].black(false);
                         i -= 2;
                     } else {
-                        Entry<K> xnode;
+                        Node<K> xnode;
                         if (dirPath[ i]) {
                             ynode = nodePath[ i];
                         } else {
@@ -354,7 +354,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
         if (tree == null) {
             return false;
         }
-        Entry<K> entry = tree;
+        Node<K> entry = tree;
         int cmp;
         int i = 0;
         final K kkey = (K) value;
@@ -413,7 +413,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             }
         } else {
             boolean color;
-            Entry<K> rnode = entry.right;
+            Node<K> rnode = entry.right;
             if (rnode.pred()) {
                 rnode.left = entry.left;
                 rnode.pred(entry.pred());
@@ -435,7 +435,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                 dirPath[ i] = true;
                 nodePath[ i++] = rnode;
             } else {
-                Entry<K> snode;
+                Node<K> snode;
                 int j = i++;
                 while (true) {
                     dirPath[ i] = false;
@@ -478,14 +478,14 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             for (; i > 0; i--) {
                 if (dirPath[ i - 1] && !nodePath[ i - 1].succ()
                         || !dirPath[ i - 1] && !nodePath[ i - 1].pred()) {
-                    Entry<K> xnode = dirPath[ i - 1] ? nodePath[ i - 1].right : nodePath[ i - 1].left;
+                    Node<K> xnode = dirPath[ i - 1] ? nodePath[ i - 1].right : nodePath[ i - 1].left;
                     if (!xnode.black()) {
                         xnode.black(true);
                         break;
                     }
                 }
                 if (!dirPath[ i - 1]) {
-                    Entry<K> wnode = nodePath[ i - 1].right;
+                    Node<K> wnode = nodePath[ i - 1].right;
                     if (!wnode.black()) {
                         wnode.black(true);
                         nodePath[ i - 1].black(false);
@@ -513,7 +513,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                         wnode.black(false);
                     } else {
                         if (wnode.succ() || wnode.right.black()) {
-                            Entry<K> ynode = wnode.left;
+                            Node<K> ynode = wnode.left;
                             ynode.black(true);
                             wnode.black(false);
                             wnode.left = ynode.right;
@@ -545,7 +545,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                         break;
                     }
                 } else {
-                    Entry<K> wnode = nodePath[ i - 1].left;
+                    Node<K> wnode = nodePath[ i - 1].left;
                     if (!wnode.black()) {
                         wnode.black(true);
                         nodePath[ i - 1].black(false);
@@ -573,7 +573,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                         wnode.black(false);
                     } else {
                         if (wnode.pred() || wnode.left.black()) {
-                            Entry<K> ynode = wnode.right;
+                            Node<K> ynode = wnode.right;
                             ynode.black(true);
                             wnode.black(false);
                             wnode.right = ynode.left;
@@ -621,7 +621,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
     @SuppressWarnings("unchecked")
     @Override
     public boolean contains(Object value) {
-        return findKey((K) value) != null;
+        return findNode((K) value) != null;
     }
 
     @Override
@@ -691,9 +691,9 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
      * tree.
      */
     @SuppressWarnings("unchecked")
-    private Entry<K> readTree(java.io.ObjectInputStream istream, int n, Entry<K> pred, Entry<K> succ) throws java.io.IOException, ClassNotFoundException {
+    private Node<K> readTree(java.io.ObjectInputStream istream, int n, Node<K> pred, Node<K> succ) throws java.io.IOException, ClassNotFoundException {
         if (n == 1) {
-            final Entry<K> top = new Entry<>((K) istream.readObject());
+            final Node<K> top = new Node<>((K) istream.readObject());
             top.pred(pred);
             top.succ(succ);
             top.black(true);
@@ -702,9 +702,9 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
         if (n == 2) {
             /* We handle separately this case so that recursion will
              *always* be on nonempty subtrees. */
-            final Entry<K> top = new Entry<>((K) istream.readObject());
+            final Node<K> top = new Node<>((K) istream.readObject());
             top.black(true);
-            top.right(new Entry<>((K) istream.readObject()));
+            top.right(new Node<>((K) istream.readObject()));
             top.right.pred(top);
             top.pred(pred);
             top.right.succ(succ);
@@ -712,7 +712,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
         }
         // The right subtree is the largest one.
         final int rightN = n / 2, leftN = n - rightN - 1;
-        final Entry<K> top = new Entry<>();
+        final Node<K> top = new Node<>();
         top.left(readTree(istream, leftN, pred, top));
         top.key = (K) istream.readObject();
         top.black(true);
@@ -728,7 +728,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
         allocatePaths();
         if (count != 0) {
             tree = readTree(istream, count, null, null);
-            Entry<K> entry;
+            Node<K> entry;
             entry = tree;
             while (entry.left() != null) {
                 entry = entry.left();
@@ -745,13 +745,13 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
     /**
      * This class represent an entry in a tree set.
      *
-     * <P>We use the only "metadata", i.e., {@link Entry#info}, end store
+     * <P>We use the only "metadata", i.e., {@link Node#info}, end store
      * information about color, predecessor status and successor status.
      *
      * <P>Note that since the class is recursive, it can be considered
      * equivalently a tree.
      */
-    protected static final class Entry<K> {
+    private static final class Node<K> {
 
         /**
          * The the bit in this mask is true, the node is black.
@@ -769,22 +769,20 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * The key of this entry.
          */
         K key;
-        /**
-         * The pointers to the left and right subtrees.
-         */
-        Entry<K> left,
 
         /**
-         * The pointers end the left and right subtrees.
-         */
-        right;
+		 * The pointers to the left and right subtrees.
+		 */
+		Node<K> left;
+
+		Node<K> right;
         /**
          * This integers holds different information in different bits (see
          * {@link #SUCC_MASK}, {@link #PRED_MASK} and {@link #BLACK_MASK}).
          */
         int info;
 
-        Entry() {
+        Node() {
         }
 
         /**
@@ -792,7 +790,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          *
          * @param key a key.
          */
-        Entry(K key) {
+        Node(K key) {
             this.key = key;
             info = SUCC_MASK | PRED_MASK;
         }
@@ -803,7 +801,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * @return the left subtree (<code>null</code> if the left subtree is
          * empty).
          */
-        Entry<K> left() {
+        Node<K> left() {
             return (info & PRED_MASK) != 0 ? null : left;
         }
 
@@ -813,7 +811,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * @return the right subtree (<code>null</code> if the right subtree is
          * empty).
          */
-        Entry<K> right() {
+        Node<K> right() {
             return (info & SUCC_MASK) != 0 ? null : right;
         }
 
@@ -868,7 +866,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          *
          * @param pred the predecessr.
          */
-        void pred(Entry<K> pred) {
+        void pred(Node<K> pred) {
             info |= PRED_MASK;
             left = pred;
         }
@@ -878,7 +876,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          *
          * @param succ the successor.
          */
-        void succ(Entry<K> succ) {
+        void succ(Node<K> succ) {
             info |= SUCC_MASK;
             right = succ;
         }
@@ -888,7 +886,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          *
          * @param left the new left subtree.
          */
-        void left(Entry<K> left) {
+        void left(Node<K> left) {
             info &= ~PRED_MASK;
             this.left = left;
         }
@@ -898,7 +896,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          *
          * @param right the new right subtree.
          */
-        void right(Entry<K> right) {
+        void right(Node<K> right) {
             info &= ~SUCC_MASK;
             this.right = right;
         }
@@ -932,8 +930,8 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * @return the next entry (<code>null</code>) if this is the last
          * entry).
          */
-        Entry<K> next() {
-            Entry<K> next = this.right;
+        Node<K> next() {
+            Node<K> next = this.right;
             if ((info & SUCC_MASK) == 0) {
                 while ((next.info & PRED_MASK) == 0) {
                     next = next.left;
@@ -948,8 +946,8 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * @return the previous entry (<code>null</code>) if this is the first
          * entry).
          */
-        Entry<K> prev() {
-            Entry<K> prev = this.left;
+        Node<K> prev() {
+            Node<K> prev = this.left;
             if ((info & PRED_MASK) == 0) {
                 while ((prev.info & SUCC_MASK) == 0) {
                     prev = prev.right;
@@ -958,25 +956,6 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             return prev;
         }
 
-        @Override
-        public boolean equals(Object object) {
-            if (!(object instanceof Entry)) {
-                return false;
-            }
-            Entry<?> entry = (Entry<?>) object;
-            return ((key) == null ? (entry.key) == null : (key).equals(entry.key));
-        }
-
-        @Override
-        public int hashCode() {
-            return ((key) == null ? 0 : (key).hashCode());
-        }
-
-        @Override
-        public String toString() {
-            return String.valueOf(key);
-        }
-
     }
 
     /**
@@ -991,18 +970,18 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * {@link java.util.ListIterator#previous()} (or
          * <code>null</code> if no previous entry exists).
          */
-        Entry<K> prev;
+        Node<K> prev;
         /**
          * The entry that will be returned by the next call end
          * {@link java.util.ListIterator#next()} (or
          * <code>null</code> if no next entry exists).
          */
-        Entry<K> next;
+        Node<K> next;
         /**
          * The last entry that was returned (or
          * <code>null</code> if we did not iterate or used {@link #remove()}).
          */
-        Entry<K> curr;
+        Node<K> curr;
         /**
          * The current index (in the sense of a {@link java.util.ListIterator}).
          * Note that this value is not meaningful when this iterator has been
@@ -1015,7 +994,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
         }
 
         TreeIterator(K key) {
-            if ((next = locateKey(key)) != null) {
+            if ((next = locateNode(key)) != null) {
                 if (compare(next.key, key) <= 0) {
                     prev = next;
                     next = next.next();
@@ -1039,7 +1018,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             next = next.next();
         }
 
-        Entry<K> nextEntry() {
+        Node<K> nextEntry() {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
@@ -1063,7 +1042,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
             prev = prev.prev();
         }
 
-        Entry<K> previousEntry() {
+        Node<K> previousEntry() {
             if (!hasPrevious()) {
                 throw new NoSuchElementException();
             }
@@ -1126,16 +1105,16 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * @return the first entry of this subset, or <code>null</code> if the
          * subset is empty.
          */
-        public RBTreeSet.Entry<K> firstEntry() {
+        public RBTreeSet.Node<K> firstEntry() {
             if (tree == null) {
                 return null;
             }
             // If this subset goes end -infinity, we return the main set first entry; otherwise, we locate the start of the set.
-            RBTreeSet.Entry<K> entry;
+            RBTreeSet.Node<K> entry;
             if (bottom) {
                 entry = firstEntry;
             } else {
-                entry = locateKey(begin);
+                entry = locateNode(begin);
                 // If we find either the start or something greater we're OK.
                 if (compare(entry.key, begin) < 0) {
                     entry = entry.next();
@@ -1154,16 +1133,16 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
          * @return the last entry of this subset, or <code>null</code> if the
          * subset is empty.
          */
-        public RBTreeSet.Entry<K> lastEntry() {
+        public RBTreeSet.Node<K> lastEntry() {
             if (tree == null) {
                 return null;
             }
             // If this subset goes end infinity, we return the main set last entry; otherwise, we locate the end of the set.
-            RBTreeSet.Entry<K> entry;
+            RBTreeSet.Node<K> entry;
             if (top) {
                 entry = lastEntry;
             } else {
-                entry = locateKey(end);
+                entry = locateNode(end);
                 // If we find something smaller than the end we're OK.
                 if (compare(entry.key, end) >= 0) {
                     entry = entry.prev();
@@ -1178,7 +1157,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
 
         @Override
         public K first() {
-            RBTreeSet.Entry<K> entry = firstEntry();
+            RBTreeSet.Node<K> entry = firstEntry();
             if (entry == null) {
                 throw new NoSuchElementException();
             }
@@ -1187,7 +1166,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
 
         @Override
         public K last() {
-            RBTreeSet.Entry<K> entry = lastEntry();
+            RBTreeSet.Node<K> entry = lastEntry();
             if (entry == null) {
                 throw new NoSuchElementException();
             }
@@ -1208,7 +1187,7 @@ public class RBTreeSet<K> extends ASortedSet<K> implements java.io.Serializable
                     } else if (!top && compare(key, (prev = lastEntry()).key) >= 0) {
                         next = null;
                     } else {
-                        next = locateKey(key);
+                        next = locateNode(key);
                         if (compare(next.key, key) <= 0) {
                             prev = next;
                             next = next.next();