public void insertNode(AVEntry entry) { if (root == null) { root = new AVEntryTreeNode(entry); size++; return; } if (keyComp(root.getKey(), entry.getStartBits()) == 1) // entry > root { root.rNode = insertNode(root.rNode, entry); } else { root.lNode = insertNode(root.lNode, entry); } root = treeBalance(root); }
private AVEntryTreeNode insertNode(AVEntryTreeNode node, AVEntry entry) { if (node == null) { size++; return(new AVEntryTreeNode(entry)); } if (keyComp(node.getKey(), entry.getStartBits()) == 1) // entry > node { node.rNode = insertNode(node.rNode, entry); } else { node.lNode = insertNode(node.lNode, entry); } node = treeBalance(node); return(node); }
private AVEntryTreeNode findNode(byte[] key, AVEntryTreeNode node) { int res = keyComp(node.getKey(), key); if (res == 0) { return(node); } else if (res == 1 && node.rNode != null) { return(findNode(key, node.rNode)); } else if (res == -1 && node.lNode != null) { return(findNode(key, node.lNode)); } else { return(null); } }