()
| 929 | } |
| 930 | |
| 931 | public int size() { |
| 932 | Node<K, V> from, to; |
| 933 | int fromIndex, toIndex; |
| 934 | if (hasStart) { |
| 935 | setFirstKey(); |
| 936 | from = firstKeyNode; |
| 937 | fromIndex = firstKeyIndex; |
| 938 | } else { |
| 939 | from = minimum(backingMap.root); |
| 940 | fromIndex = from == null ? 0 : from.left_idx; |
| 941 | } |
| 942 | if (from == null) { |
| 943 | return 0; |
| 944 | } |
| 945 | if (hasEnd) { |
| 946 | setLastKey(); |
| 947 | to = lastKeyNode; |
| 948 | toIndex = lastKeyIndex; |
| 949 | java.lang.Comparable<K> object = backingMap.comparator == null ? toComparable((K) endKey) |
| 950 | : null; |
| 951 | if (to == null){ |
| 952 | return 0; |
| 953 | } else if (backingMap.cmp(object, endKey, to.keys[toIndex]) != 0) { |
| 954 | if (toIndex != to.keys.length) { |
| 955 | toIndex++; |
| 956 | } else { |
| 957 | to = to.next; |
| 958 | toIndex = to == null ? 0 : to.left_idx; |
| 959 | } |
| 960 | } |
| 961 | } else { |
| 962 | to = maximum(backingMap.root); |
| 963 | toIndex = to == null ? 0 : to.right_idx; |
| 964 | } |
| 965 | if (to == null) { |
| 966 | return 0; |
| 967 | } |
| 968 | // the last element of submap if exist should be ignored |
| 969 | if (from == to) { |
| 970 | return toIndex - fromIndex + (hasEnd ? 0 : 1); |
| 971 | } |
| 972 | int sum = 0; |
| 973 | while (from != to) { |
| 974 | sum += (from.right_idx - fromIndex + 1); |
| 975 | from = from.next; |
| 976 | fromIndex = from.left_idx; |
| 977 | } |
| 978 | return sum + toIndex - fromIndex + (hasEnd ? 0 : 1); |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | static class SubMapValuesCollection<K, V> extends AbstractCollection<V> { |
nothing calls this directly
no test coverage detected