9 package javolution.util.internal.map.sorted;
11 import java.util.Iterator;
12 import java.util.NoSuchElementException;
33 if (
ahead)
return true;
45 public Entry<K, V>
next() {
52 public void remove() {
64 if ((
from !=
null) && (
to !=
null)
66 "from: " +
from +
", to: " +
to);
71 @SuppressWarnings(
"unchecked")
76 if ((
to !=
null) && (cmp.
compare((K) key,
to) >= 0))
return false;
77 return target().containsKey(key);
83 Iterator<Entry<K, V>> it =
iterator();
84 if (!it.hasNext())
throw new NoSuchElementException();
85 return it.next().getKey();
88 @SuppressWarnings(
"unchecked")
90 public V
get(Object key) {
93 if ((
to !=
null) && (cmp.
compare((K) key,
to) >= 0))
return null;
104 return target().keyComparator();
109 if (
to ==
null)
return target().lastKey();
110 Iterator<Entry<K, V>> it =
iterator();
111 if (!it.hasNext())
throw new NoSuchElementException();
112 Entry<K, V> last = it.next();
113 while (it.hasNext()) {
116 return last.getKey();
120 public V
put(K key, V value) {
122 if ((
from !=
null) && (cmp.
compare((K) key,
from) < 0))
throw new IllegalArgumentException(
123 "Key: " + key +
" outside of this sub-map bounds");
124 if ((
to !=
null) && (cmp.
compare((K) key,
to) >= 0))
throw new IllegalArgumentException(
125 "Key: " + key +
" outside of this sub-map bounds");
126 return target().put(key, value);
129 @SuppressWarnings(
"unchecked")
131 public V
remove(Object key) {
134 if ((
to !=
null) && (cmp.
compare((K) key,
to) >= 0))
return null;
135 return target().remove(key);
140 return target().valueComparator();