io.permazen.index.Index1 Maven / Gradle / Ivy
Show all versions of permazen-util Show documentation
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen.index;
import io.permazen.tuple.Tuple2;
import io.permazen.util.Bounds;
import java.util.NavigableMap;
import java.util.NavigableSet;
/**
* An index on a single field.
*
*
* Indexes are read-only and "live", always reflecting the current transaction state.
*
* @param indexed value type
* @param index target type
* @see io.permazen.index
*/
public interface Index1 extends Index {
@Override
default int numberOfFields() {
return 1;
}
/**
* View this index as a {@link NavigableSet} of tuples.
*
* @return {@link NavigableSet} of tuples containing indexed value and target value
*/
NavigableSet> asSet();
/**
* View this index as a {@link NavigableMap} of target values keyed by indexed value.
*
* @return {@link NavigableMap} from indexed value to the corresponding set of target objects
*/
NavigableMap> asMap();
/**
* Impose {@link Bounds} that restrict the range of the indexed value.
*
* @param bounds bounds to impose on the indexed value
* @return a view of this index in which only values within {@code bounds} are visible
*/
Index1 withValueBounds(Bounds bounds);
/**
* Impose {@link Bounds} that restrict the range of the target value.
*
* @param bounds bounds to impose on the target value
* @return a view of this index in which only target values within {@code bounds} are visible
*/
Index1 withTargetBounds(Bounds bounds);
}