io.sirix.index.art.DescendingSubMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirix-core Show documentation
Show all versions of sirix-core Show documentation
SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.
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);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy