| 1089 | } |
| 1090 | |
| 1091 | static protected class DescendingMap<K,V> extends AbstractMap<K,V> implements ConcurrentNavigableMap2<K,V> { |
| 1092 | |
| 1093 | protected final ConcurrentNavigableMapExtra<K,V> m; |
| 1094 | |
| 1095 | protected final K lo; |
| 1096 | protected final boolean loInclusive; |
| 1097 | |
| 1098 | protected final K hi; |
| 1099 | protected final boolean hiInclusive; |
| 1100 | |
| 1101 | public DescendingMap(ConcurrentNavigableMapExtra<K,V> m, K lo, boolean loInclusive, K hi, boolean hiInclusive) { |
| 1102 | this.m = m; |
| 1103 | this.lo = lo; |
| 1104 | this.loInclusive = loInclusive; |
| 1105 | this.hi = hi; |
| 1106 | this.hiInclusive = hiInclusive; |
| 1107 | if(lo!=null && hi!=null && m.comparator().compare(lo, hi)>0){ |
| 1108 | throw new IllegalArgumentException(); |
| 1109 | } |
| 1110 | |
| 1111 | |
| 1112 | } |
| 1113 | |
| 1114 | |
| 1115 | /* ---------------- Map API methods -------------- */ |
| 1116 | |
| 1117 | @Override |
| 1118 | public boolean containsKey(Object key) { |
| 1119 | if (key == null) throw new NullPointerException(); |
| 1120 | K k = (K)key; |
| 1121 | return inBounds(k) && m.containsKey(k); |
| 1122 | } |
| 1123 | |
| 1124 | @Override |
| 1125 | public V get(Object key) { |
| 1126 | if (key == null) throw new NullPointerException(); |
| 1127 | K k = (K)key; |
| 1128 | return ((!inBounds(k)) ? null : m.get(k)); |
| 1129 | } |
| 1130 | |
| 1131 | @Override |
| 1132 | public V put(K key, V value) { |
| 1133 | checkKeyBounds(key); |
| 1134 | return m.put(key, value); |
| 1135 | } |
| 1136 | |
| 1137 | @Override |
| 1138 | public V remove(Object key) { |
| 1139 | K k = (K)key; |
| 1140 | return (!inBounds(k))? null : m.remove(k); |
| 1141 | } |
| 1142 | |
| 1143 | @Override |
| 1144 | public int size() { |
| 1145 | if(hi==null && lo==null) |
| 1146 | return m.size(); |
| 1147 | |
| 1148 | Iterator<K> i = m.keyIterator(lo, loInclusive, hi, hiInclusive); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…