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