Returns the entry for the greatest key less than the specified key; if no such entry exists (i.e., the least key in the Tree is greater than the specified key), returns null .
(Object key)
| 395 | * the specified key), returns <tt>null</tt>. |
| 396 | */ |
| 397 | private Entry<K,V> getPrecedingEntry(Object key) { |
| 398 | Entry<K,V> p = root; |
| 399 | if (p==null)return null; |
| 400 | |
| 401 | while (true) { |
| 402 | int cmp = compare(key, p.key); |
| 403 | if (cmp > 0) { |
| 404 | if (p.right != null) p = p.right; |
| 405 | else return p; |
| 406 | }else{ |
| 407 | if (p.left != null) { |
| 408 | p = p.left; |
| 409 | } else { |
| 410 | Entry<K,V> parent = p.parent; |
| 411 | Entry<K,V> ch = p; |
| 412 | while (parent != null && ch == parent.left) { |
| 413 | ch = parent; |
| 414 | parent = parent.parent; |
| 415 | } |
| 416 | return parent; |
| 417 | } |
| 418 | } |
| 419 | }//while true |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * Returns the key corresonding to the specified Entry. Throw |
no test coverage detected