All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.sirix.index.art.DescendingSubMap Maven / Gradle / Ivy
package io.sirix.index.art;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.*;
final class DescendingSubMap extends NavigableSubMap {
DescendingSubMap(AdaptiveRadixTree m, boolean fromStart, K lo, boolean loInclusive, boolean toEnd, K hi,
boolean hiInclusive) {
super(m, fromStart, lo, loInclusive, toEnd, hi, hiInclusive);
}
@Override
public Comparator super K> comparator() {
return tree.comparator();
}
// create a new submap out of a submap.
// the new bounds should be within the current submap's bounds
@Override
public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
if (!inRange(fromKey, fromInclusive))
throw new IllegalArgumentException("fromKey out of range");
if (!inRange(toKey, toInclusive))
throw new IllegalArgumentException("toKey out of range");
return new DescendingSubMap<>(tree, false, toKey, toInclusive, false, fromKey, fromInclusive);
}
@Override
public NavigableMap headMap(K toKey, boolean inclusive) {
if (!inRange(toKey, inclusive))
throw new IllegalArgumentException("toKey out of range");
return new DescendingSubMap<>(tree, false, toKey, inclusive, toEnd, hi, hiInclusive);
}
@Override
public NavigableMap tailMap(K fromKey, boolean inclusive) {
if (!inRange(fromKey, inclusive))
throw new IllegalArgumentException("fromKey out of range");
return new DescendingSubMap<>(tree, fromStart, lo, loInclusive, false, fromKey, inclusive);
}
@Override
public NavigableMap descendingMap() {
NavigableMap mapView = descendingMapView;
return (mapView != null)
? mapView
: (descendingMapView = new AscendingSubMap<>(tree, fromStart, lo, loInclusive, toEnd, hi, hiInclusive));
}
@Override
Iterator keyIterator() {
return new DescendingSubMapKeyIterator(absHighest(), absLowFence());
}
@Override
Spliterator keySpliterator() {
return new DescendingSubMapKeyIterator(absHighest(), absLowFence());
}
@Override
Iterator descendingKeyIterator() {
return new SubMapKeyIterator(absLowest(), absHighFence());
}
final class DescendingEntrySetView extends EntrySetView {
@Override
public @NonNull Iterator> iterator() {
return new DescendingSubMapEntryIterator(absHighest(), absLowFence());
}
}
@Override
public Set> entrySet() {
EntrySetView es = entrySetView;
return (es != null) ? es : (entrySetView = new DescendingEntrySetView());
}
@Override
LeafNode subLowest() {
return absHighest();
}
@Override
LeafNode subHighest() {
return absLowest();
}
@Override
LeafNode subCeiling(K key) {
return absFloor(key);
}
@Override
LeafNode subHigher(K key) {
return absLower(key);
}
@Override
LeafNode subFloor(K key) {
return absCeiling(key);
}
@Override
LeafNode subLower(K key) {
return absHigher(key);
}
}