|
|
@@ -95,7 +95,7 @@ public abstract class SortedLookup<K> extends Lookup<K> implements SortedMap<K,
|
|
|
*/
|
|
|
@Override
|
|
|
public final ASortedSet<LookupEntry<K>> fastEntrySet() {
|
|
|
- return new EntrySet();
|
|
|
+ return new EntrySet(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -369,20 +369,23 @@ public abstract class SortedLookup<K> extends Lookup<K> implements SortedMap<K,
|
|
|
|
|
|
}
|
|
|
|
|
|
- protected class EntrySet extends ASortedSet<LookupEntry<K>> {
|
|
|
+ protected static class EntrySet<K> extends ASortedSet<LookupEntry<K>> {
|
|
|
+
|
|
|
+ private final SortedLookup<K> that;
|
|
|
|
|
|
- public EntrySet() {
|
|
|
- super(SortedLookup.this.entrySet().comparator());
|
|
|
+ public EntrySet(SortedLookup<K> that) {
|
|
|
+ super((entry1, entry2) -> that.acmp.compare(entry1.getKey(), entry2.getKey()));
|
|
|
+ this.that = that;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Iterator<LookupEntry<K>> iterator() {
|
|
|
- return entryIterator();
|
|
|
+ return that.entryIterator();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Iterator<LookupEntry<K>> iterator(LookupEntry<K> from) {
|
|
|
- return entryIterator(from.getKey());
|
|
|
+ return that.entryIterator(from.getKey());
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@@ -392,7 +395,7 @@ public abstract class SortedLookup<K> extends Lookup<K> implements SortedMap<K,
|
|
|
return false;
|
|
|
}
|
|
|
Map.Entry<K, Integer> entry = (Map.Entry<K, Integer>) object;
|
|
|
- LookupEntry<K> found = findEntry(entry.getKey());
|
|
|
+ LookupEntry<K> found = that.findEntry(entry.getKey());
|
|
|
return entry.equals(found);
|
|
|
}
|
|
|
|
|
|
@@ -403,9 +406,9 @@ public abstract class SortedLookup<K> extends Lookup<K> implements SortedMap<K,
|
|
|
return false;
|
|
|
}
|
|
|
Map.Entry<K, Integer> entry = (Map.Entry<K, Integer>) object;
|
|
|
- LookupEntry<K> found = findEntry(entry.getKey());
|
|
|
+ LookupEntry<K> found = that.findEntry(entry.getKey());
|
|
|
if (found != null) {
|
|
|
- SortedLookup.this.removeInt(found.getIntValue());
|
|
|
+ that.removeInt(found.getIntValue());
|
|
|
}
|
|
|
return found != null;
|
|
|
}
|
|
|
@@ -421,44 +424,44 @@ public abstract class SortedLookup<K> extends Lookup<K> implements SortedMap<K,
|
|
|
|
|
|
@Override
|
|
|
public boolean isEmpty() {
|
|
|
- return !entryIterator().hasNext();
|
|
|
+ return !that.entryIterator().hasNext();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void clear() {
|
|
|
- SortedLookup.this.clear();
|
|
|
+ that.clear();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public LookupEntry<K> first() {
|
|
|
- return SortedLookup.this.firstEntry();
|
|
|
+ return that.firstEntry();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public LookupEntry<K> last() {
|
|
|
- return SortedLookup.this.lastEntry();
|
|
|
+ return that.lastEntry();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ASortedSet<LookupEntry<K>> subSet(LookupEntry<K> begin, LookupEntry<K> end) {
|
|
|
- return subMap(begin.getKey(), end.getKey()).fastEntrySet();
|
|
|
+ return that.subMap(begin.getKey(), end.getKey()).fastEntrySet();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ASortedSet<LookupEntry<K>> headSet(LookupEntry<K> end) {
|
|
|
- return headMap(end.getKey()).fastEntrySet();
|
|
|
+ return that.headMap(end.getKey()).fastEntrySet();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ASortedSet<LookupEntry<K>> tailSet(LookupEntry<K> begin) {
|
|
|
- return tailMap(begin.getKey()).fastEntrySet();
|
|
|
+ return that.tailMap(begin.getKey()).fastEntrySet();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected ASortedSet<LookupEntry<K>> subset(LookupEntry<K> begin, boolean bottom, LookupEntry<K> end, boolean top) {
|
|
|
K begkey = (null == begin) ? null : begin.getKey();
|
|
|
K endkey = (null == end) ? null : end.getKey();
|
|
|
- return submap(begkey, bottom, endkey, top).fastEntrySet();
|
|
|
+ return that.submap(begkey, bottom, endkey, top).fastEntrySet();
|
|
|
}
|
|
|
}
|
|
|
|