do the actual lookup of a piece of data @param data the key or value to be looked up @param index _KEY or _VALUE @return the desired Node, or null if there is no mapping of the specified data
(Comparable data, int index)
| 461 | * specified data |
| 462 | */ |
| 463 | public Node lookup(Comparable data, int index) |
| 464 | { |
| 465 | Node rval = null; |
| 466 | Node node = _root[ index ]; |
| 467 | |
| 468 | while (node != null) |
| 469 | { |
| 470 | int cmp = compare(data, node.getData(index)); |
| 471 | |
| 472 | if (cmp == 0) |
| 473 | { |
| 474 | rval = node; |
| 475 | break; |
| 476 | } |
| 477 | node = (cmp < 0) ? node.getLeft(index) |
| 478 | : node.getRight(index); |
| 479 | } |
| 480 | return rval; |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | * Compare two objects |
no test coverage detected