()
| 755 | } |
| 756 | |
| 757 | private void setLastKey() { |
| 758 | if (lastKeyModCount == backingMap.modCount) { |
| 759 | return; |
| 760 | } |
| 761 | java.lang.Comparable<K> object = backingMap.comparator == null ? toComparable((K) endKey) |
| 762 | : null; |
| 763 | K key = (K) endKey; |
| 764 | Node<K, V> node = backingMap.root; |
| 765 | Node<K, V> foundNode = null; |
| 766 | int foundIndex = -1; |
| 767 | TOP_LOOP: while (node != null) { |
| 768 | K[] keys = node.keys; |
| 769 | int left_idx = node.left_idx; |
| 770 | // to be compatible with RI on null-key comparator |
| 771 | int result = object != null ? object.compareTo(keys[left_idx]) : -backingMap.comparator.compare( |
| 772 | keys[left_idx] , key); |
| 773 | //int result = - backingMap.cmp(object, keys[left_idx] , key); |
| 774 | if (result < 0) { |
| 775 | node = node.left; |
| 776 | } else { |
| 777 | int right_idx = node.right_idx; |
| 778 | if (left_idx != right_idx) { |
| 779 | result = backingMap.cmp(object, key, keys[right_idx]); |
| 780 | } |
| 781 | if (result > 0) { |
| 782 | foundNode = node; |
| 783 | foundIndex = right_idx; |
| 784 | node = node.right; |
| 785 | } else if (result == 0) { |
| 786 | if (node.left_idx == node.right_idx) { |
| 787 | foundNode = node.prev; |
| 788 | if (foundNode != null) { |
| 789 | foundIndex = foundNode.right_idx - 1; |
| 790 | } |
| 791 | } else { |
| 792 | foundNode = node; |
| 793 | foundIndex = right_idx; |
| 794 | } |
| 795 | break; |
| 796 | } else { /* search in node */ |
| 797 | foundNode = node; |
| 798 | foundIndex = left_idx; |
| 799 | int low = left_idx + 1, mid = 0, high = right_idx - 1; |
| 800 | while (low <= high) { |
| 801 | mid = (low + high) >>> 1; |
| 802 | result = backingMap.cmp(object, key, keys[mid]); |
| 803 | if (result > 0) { |
| 804 | foundNode = node; |
| 805 | foundIndex = mid; |
| 806 | low = mid + 1; |
| 807 | } else if (result == 0) { |
| 808 | foundNode = node; |
| 809 | foundIndex = mid; |
| 810 | break TOP_LOOP; |
| 811 | } else { |
| 812 | high = mid - 1; |
| 813 | } |
| 814 | } |
no test coverage detected