Gets the entry corresponding to the specified key; if no such entry exists, returns the entry for the least key greater than the specified key; if no such entry exists (i.e., the greatest key in the Tree is less than the specified key), returns null .
(Object key)
| 360 | * than the specified key), returns <tt>null</tt>. |
| 361 | */ |
| 362 | private Entry<K,V> getCeilEntry(Object key) { |
| 363 | Entry<K,V> p = root; |
| 364 | if (p==null) |
| 365 | return null; |
| 366 | |
| 367 | while (true) { |
| 368 | int cmp = compare(key, p.key); |
| 369 | if (cmp == 0) { |
| 370 | return p; |
| 371 | } else if (cmp < 0) { |
| 372 | if (p.left != null) |
| 373 | p = p.left; |
| 374 | else |
| 375 | return p; |
| 376 | } else { |
| 377 | if (p.right != null) { |
| 378 | p = p.right; |
| 379 | } else { |
| 380 | Entry<K,V> parent = p.parent; |
| 381 | Entry<K,V> ch = p; |
| 382 | while (parent != null && ch == parent.right) { |
| 383 | ch = parent; |
| 384 | parent = parent.parent; |
| 385 | } |
| 386 | return parent; |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * Returns the entry for the greatest key less than the specified key; if |
no test coverage detected