Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Private put() method */
- private Node<Key, Value> put(Node<Key, Value> x, Key key, Value value) {
- if (x == null) { // 2
- return new Node<Key, Value>(key, value); // 2
- }
- int cmp = key.compareTo(x.key); // 3
- if (cmp < 0) { // 4
- x.left = put(x.left, key, value); // 4
- } else if (cmp > 0) { // 5
- x.right = put(x.right, key, value); // 5
- } else { // 6
- x.value = value; // 6
- }
- x.size = 1 + size(x.left) + size(x.right); // 7
- return x; // 8
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement