()
| 755 | } |
| 756 | |
| 757 | public int size() { |
| 758 | Node<K, V> from, to; |
| 759 | int fromIndex, toIndex; |
| 760 | if (hasStart) { |
| 761 | setFirstKey(); |
| 762 | from = firstKeyNode; |
| 763 | fromIndex = firstKeyIndex; |
| 764 | } else { |
| 765 | from = minimum(backingMap.root); |
| 766 | fromIndex = from == null ? 0 : from.left_idx; |
| 767 | } |
| 768 | if (from == null) { |
| 769 | return 0; |
| 770 | } |
| 771 | if (hasEnd) { |
| 772 | setLastKey(); |
| 773 | to = lastKeyNode; |
| 774 | toIndex = lastKeyIndex; |
| 775 | } else { |
| 776 | to = maximum(backingMap.root); |
| 777 | toIndex = to == null ? 0 : to.right_idx; |
| 778 | } |
| 779 | if (to == null) { |
| 780 | return 0; |
| 781 | } |
| 782 | if (from == to) { |
| 783 | return toIndex - fromIndex + 1; |
| 784 | } |
| 785 | int sum = 0; |
| 786 | while (from != to) { |
| 787 | sum += (from.right_idx - fromIndex + 1); |
| 788 | from = from.next; |
| 789 | fromIndex = from.left_idx; |
| 790 | } |
| 791 | return sum + toIndex - fromIndex + 1; |
| 792 | } |
| 793 | |
| 794 | // private void readObject(ObjectInputStream stream) throws IOException, |
| 795 | // ClassNotFoundException { |
nothing calls this directly
no test coverage detected