1 |
|
/* |
2 |
< |
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. |
2 |
> |
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
3 |
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
|
* |
5 |
|
* This code is free software; you can redistribute it and/or modify it |
93 |
|
* @param <V> the type of mapped values |
94 |
|
* |
95 |
|
* @author Josh Bloch and Doug Lea |
96 |
– |
* @version %I%, %G% |
96 |
|
* @see Map |
97 |
|
* @see HashMap |
98 |
|
* @see Hashtable |
1021 |
|
} |
1022 |
|
|
1023 |
|
Iterator<K> descendingKeyIterator() { |
1024 |
< |
return new DescendingKeyIterator(getFirstEntry()); |
1024 |
> |
return new DescendingKeyIterator(getLastEntry()); |
1025 |
|
} |
1026 |
|
|
1027 |
|
static final class KeySet<E> extends AbstractSet<E> implements NavigableSet<E> { |
1068 |
|
} |
1069 |
|
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, |
1070 |
|
E toElement, boolean toInclusive) { |
1071 |
< |
return new TreeSet<E>(m.subMap(fromElement, fromInclusive, |
1072 |
< |
toElement, toInclusive)); |
1071 |
> |
return new KeySet<E>(m.subMap(fromElement, fromInclusive, |
1072 |
> |
toElement, toInclusive)); |
1073 |
|
} |
1074 |
|
public NavigableSet<E> headSet(E toElement, boolean inclusive) { |
1075 |
< |
return new TreeSet<E>(m.headMap(toElement, inclusive)); |
1075 |
> |
return new KeySet<E>(m.headMap(toElement, inclusive)); |
1076 |
|
} |
1077 |
|
public NavigableSet<E> tailSet(E fromElement, boolean inclusive) { |
1078 |
< |
return new TreeSet<E>(m.tailMap(fromElement, inclusive)); |
1078 |
> |
return new KeySet<E>(m.tailMap(fromElement, inclusive)); |
1079 |
|
} |
1080 |
|
public SortedSet<E> subSet(E fromElement, E toElement) { |
1081 |
|
return subSet(fromElement, true, toElement, false); |
1087 |
|
return tailSet(fromElement, true); |
1088 |
|
} |
1089 |
|
public NavigableSet<E> descendingSet() { |
1090 |
< |
return new TreeSet(m.descendingMap()); |
1090 |
> |
return new KeySet(m.descendingMap()); |
1091 |
|
} |
1092 |
|
} |
1093 |
|
|
2142 |
|
// If strictly internal, copy successor's element to p and then make p |
2143 |
|
// point to successor. |
2144 |
|
if (p.left != null && p.right != null) { |
2145 |
< |
Entry<K,V> s = successor (p); |
2145 |
> |
Entry<K,V> s = successor(p); |
2146 |
|
p.key = s.key; |
2147 |
|
p.value = s.value; |
2148 |
|
p = s; |