Utility to create submaps, where given bounds override unbounded(null) ones and/or are checked against bounded ones.
(K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive)
| 925 | * unbounded(null) ones and/or are checked against bounded ones. |
| 926 | */ |
| 927 | private SubMap<K,V> newSubMap(K fromKey, |
| 928 | boolean fromInclusive, |
| 929 | K toKey, |
| 930 | boolean toInclusive) { |
| 931 | |
| 932 | // if(fromKey!=null && toKey!=null){ |
| 933 | // int comp = m.comparator.compare(fromKey, toKey); |
| 934 | // if((fromInclusive||!toInclusive) && comp==0) |
| 935 | // throw new IllegalArgumentException(); |
| 936 | // } |
| 937 | |
| 938 | if (lo != null) { |
| 939 | if (fromKey == null) { |
| 940 | fromKey = lo; |
| 941 | fromInclusive = loInclusive; |
| 942 | } |
| 943 | else { |
| 944 | int c = m.comparator().compare(fromKey, lo); |
| 945 | if (c < 0 || (c == 0 && !loInclusive && fromInclusive)) |
| 946 | throw new IllegalArgumentException("key out of range"); |
| 947 | } |
| 948 | } |
| 949 | if (hi != null) { |
| 950 | if (toKey == null) { |
| 951 | toKey = hi; |
| 952 | toInclusive = hiInclusive; |
| 953 | } |
| 954 | else { |
| 955 | int c = m.comparator().compare(toKey, hi); |
| 956 | if (c > 0 || (c == 0 && !hiInclusive && toInclusive)) |
| 957 | throw new IllegalArgumentException("key out of range"); |
| 958 | } |
| 959 | } |
| 960 | return new SubMap<K,V>(m, fromKey, fromInclusive, |
| 961 | toKey, toInclusive); |
| 962 | } |
| 963 | |
| 964 | @Override |
| 965 | public SubMap<K,V> subMap(K fromKey, |
no test coverage detected