Ois,
Eu gostaria de remover uma linha do método de inserção em uma árvore rubro-negra, classe RedBlackBST
. Posso remover a linha indicada abaixo.
/************************************************************************* * Red-black insertion *************************************************************************/ // insert the key-value pair; overwrite the old value with the new value // if the key is already present public void put(Key key, Value val) { root = put(root, key, val); root.color = BLACK; assert check(); } // insert the key-value pair in the subtree rooted at h private Node put(Node h, Key key, Value val) { if (h == null) return new Node(key, val, RED, 1); int cmp = key.compareTo(h.key); if (cmp < 0) h.left = put(h.left, key, val); else if (cmp > 0) h.right = put(h.right, key, val); else h.val = val; // fix-up any right-leaning links if (isRed(h.right) && !isRed(h.left)) h = rotateLeft(h); if (isRed(h.left) && isRed(h.left.left)) h = rotateRight(h); if (isRed(h.left) && isRed(h.right)) flipColors(h); h.N = size(h.left) + size(h.right) + 1; // Quero remover essa linha! // Posso? return h; }