Interface OrderedKeys
- All Superinterfaces:
AutoCloseable,LongSizedDataStructure,SafeCloseable
- All Known Subinterfaces:
Index,ReadOnlyIndex,SingleRangeMixin
- All Known Implementing Classes:
CurrentOnlyIndex,OrderedKeysAsChunkImpl,OrderedKeysKeyIndicesChunkImpl,OrderedKeysKeyRangesChunkImpl,RspOrderedKeys,ShiftedOrderedKeys,SingleRangeOrderedKeys,SortedIndex,SortedRangesOrderedKeys,TreeIndex
public interface OrderedKeys extends SafeCloseable, LongSizedDataStructure
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceOrderedKeys.IteratorIterator for consuming anOrderedKeysby ordered subsets. -
Field Summary
Fields Modifier and Type Field Description static OrderedKeysEMPTYImmutable, re-usableOrderedKeysinstance. -
Method Summary
Modifier and Type Method Description IndexasIndex()Get anIndexrepresentation of thisOrderedKeys.LongChunk<Attributes.OrderedKeyIndices>asKeyIndicesChunk()Get aLongChunkrepresentation of the individual keys in thisOrderedKeys.LongChunk<Attributes.OrderedKeyRanges>asKeyRangesChunk()Get aLongChunkrepresentation of key ranges in thisOrderedKeys.default voidclose()Free any resources associated with this object.voidfillKeyIndicesChunk(WritableLongChunk<? extends Attributes.KeyIndices> chunkToFill)Fill the suppliedWritableLongChunkwith individual keys from thisOrderedKeys.voidfillKeyRangesChunk(WritableLongChunk<Attributes.OrderedKeyRanges> chunkToFill)Fill the suppliedWritableLongChunkwith key ranges from thisOrderedKeys.longfirstKey()Get the first key in thisOrderedKeys.default voidforAllLongRanges(LongRangeConsumer lrc)default voidforAllLongs(LongConsumer lc)booleanforEachLong(LongAbortableConsumer lac)For as long as the consumer wants more keys, call accept on the consumer with the individual key instances in this OrderedKeys, in increasing order.booleanforEachLongRange(LongRangeAbortableConsumer larc)For as long as the consumer wants more ranges, call accept on the consumer with the individual key ranges in this OrderedKeys, in increasing order.static OrderedKeysforRange(long firstKey, long lastKey)longgetAverageRunLengthEstimate()Get an estimate of the average (mean) length of runs of adjacent keys in thisOrderedKeys.OrderedKeysgetOrderedKeysByKeyRange(long startKeyInclusive, long endKeyInclusive)Get an ordered subset of the keys in thisOrderedKeysfor a key range.OrderedKeysgetOrderedKeysByPosition(long startPositionInclusive, long length)Get an ordered subset of the keys in thisOrderedKeysfor a position range.OrderedKeys.IteratorgetOrderedKeysIterator()Get anOrderedKeys.Iteratorover thisOrderedKeys.default booleanisContiguous()Helper to tell you if this is one contiguous range.booleanisEmpty()True if the size of thisOrderedkeysis zero.longlastKey()Get the last key in thisOrderedKeys.longsize()Get the number of keys in thisOrderedKeys.static OrderedKeystakeKeyIndicesChunkAndMakeOrderedKeys(WritableLongChunk<Attributes.OrderedKeyIndices> longChunk)Create and return a new OrderedKeys object from the provided WritableLongChunk.static OrderedKeystakeKeyRangesChunkAndMakeOrderedKeys(WritableLongChunk<Attributes.OrderedKeyRanges> longChunk)Create and return a new OrderedKeys object from the provided WritableLongChunk.static OrderedKeyswrapKeyIndicesChunkAsOrderedKeys(LongChunk<Attributes.OrderedKeyIndices> longChunk)Wrap a LongChunk as an OrderedKeys.static OrderedKeyswrapKeyRangesChunkAsOrderedKeys(LongChunk<Attributes.OrderedKeyRanges> longChunk)Wrap a LongChunk as an OrderedKeys.
-
Field Details
-
EMPTY
Immutable, re-usableOrderedKeysinstance.
-
-
Method Details
-
wrapKeyIndicesChunkAsOrderedKeys
static OrderedKeys wrapKeyIndicesChunkAsOrderedKeys(LongChunk<Attributes.OrderedKeyIndices> longChunk)Wrap a LongChunk as an OrderedKeys.- Parameters:
longChunk- A chunk to wrap as a new OrderedKeys object.- Returns:
- A new OrderedKeys object, who does not own the passed chunk.
-
wrapKeyRangesChunkAsOrderedKeys
static OrderedKeys wrapKeyRangesChunkAsOrderedKeys(LongChunk<Attributes.OrderedKeyRanges> longChunk)Wrap a LongChunk as an OrderedKeys.- Parameters:
longChunk- A chunk to wrap as a new OrderedKeys object.- Returns:
- A new OrderedKeys object, who does not own the passed chunk.
-
takeKeyIndicesChunkAndMakeOrderedKeys
static OrderedKeys takeKeyIndicesChunkAndMakeOrderedKeys(WritableLongChunk<Attributes.OrderedKeyIndices> longChunk)Create and return a new OrderedKeys object from the provided WritableLongChunk.- Parameters:
longChunk- The input chunk. The returned object will take ownership of this chunk.- Returns:
- A new OrderedKeys object, who owns the passed chunk.
-
takeKeyRangesChunkAndMakeOrderedKeys
static OrderedKeys takeKeyRangesChunkAndMakeOrderedKeys(WritableLongChunk<Attributes.OrderedKeyRanges> longChunk)Create and return a new OrderedKeys object from the provided WritableLongChunk.- Parameters:
longChunk- The input chunk. The returned object will take ownership of this chunk.- Returns:
- A new OrderedKeys object, who owns the passed chunk.
-
getOrderedKeysIterator
OrderedKeys.Iterator getOrderedKeysIterator()Get anOrderedKeys.Iteratorover thisOrderedKeys.- Returns:
- A new iterator, positioned at the first key
-
getOrderedKeysByPosition
Get an ordered subset of the keys in this
OrderedKeysfor a position range. The result will contain the set of keys inthisthat lie at positions in the half-open range [startPositionInclusive,startPositionInclusive + length). The returned reference is owned by the caller, who should callclose()when it is done with it.- Parameters:
startPositionInclusive- The position of the first key to includelength- The number of keys to include- Returns:
- The subset as an
OrderedKeys, which may bethis
-
getOrderedKeysByKeyRange
Get an ordered subset of the keys in this
OrderedKeysfor a key range. The returned set will be the intersection of the keys inthiswith the keys in the closed interval [startKeyInclusive,endKeyInclusive]. The returned reference is owned by the caller, who should callclose()when it is done with it.- Parameters:
startKeyInclusive- The minimum key to includeendKeyInclusive- The maximum key to include- Returns:
- The subset as an
OrderedKeys, which may bethis
-
asIndex
Index asIndex()Get anIndexrepresentation of thisOrderedKeys.- Returns:
- An
Indexrepresentation for the same keys in the same order - ApiNote:
- If you use the result across clock ticks, you may observe inconsistencies., You must not mutate the result.
-
asKeyIndicesChunk
LongChunk<Attributes.OrderedKeyIndices> asKeyIndicesChunk()Get aLongChunkrepresentation of the individual keys in thisOrderedKeys.- Returns:
- A
LongChunkcontaining the keys in thisOrderedKeys - ApiNote:
- This
OrderedKeysowns the result, which is valid only as long as thisOrderedKeysremains valid., You must not mutate the result.
-
asKeyRangesChunk
LongChunk<Attributes.OrderedKeyRanges> asKeyRangesChunk()Get aLongChunkrepresentation of key ranges in thisOrderedKeys.- Returns:
- A
LongChunkcontaining the key ranges in thisOrderedKeys - ApiNote:
- This
OrderedKeysowns the result, which is valid only as long as thisOrderedKeysremains valid., You must not mutate the result.
-
fillKeyIndicesChunk
Fill the supplied
WritableLongChunkwith individual keys from thisOrderedKeys.The chunk's capacity is assumed to be big enough.
- Parameters:
chunkToFill- A chunk to fill with individual keys
-
fillKeyRangesChunk
Fill the supplied
WritableLongChunkwith key ranges from thisOrderedKeys.The chunk's capacity is assumed to be big enough.
- Parameters:
chunkToFill- A chunk to fill with key ranges
-
isEmpty
boolean isEmpty()True if the size of thisOrderedkeysis zero.- Returns:
- True if there are no elements in this
OrderedKeys.
-
firstKey
long firstKey()Get the first key in thisOrderedKeys.- Returns:
- The first key, or
ReadOnlyIndex.NULL_KEYif there is none.
-
lastKey
long lastKey()Get the last key in thisOrderedKeys.- Returns:
- The last key, or
ReadOnlyIndex.NULL_KEYif there is none.
-
size
long size()Get the number of keys in thisOrderedKeys.- Specified by:
sizein interfaceLongSizedDataStructure- Returns:
- The size, in [0,
Long.MAX_VALUE]
-
isContiguous
default boolean isContiguous()Helper to tell you if this is one contiguous range. -
getAverageRunLengthEstimate
long getAverageRunLengthEstimate()Get an estimate of the average (mean) length of runs of adjacent keys in this
OrderedKeys.Implementations should strive to keep this method efficient (O(1) preferred) at the expense of accuracy.
Empty
OrderedKeysshould return an arbitrary valid value, usually 1.- Returns:
- An estimate of the average run length in this
OrderedKeys, in [1,size()]
-
forEachLong
For as long as the consumer wants more keys, call accept on the consumer with the individual key instances in this OrderedKeys, in increasing order.- Parameters:
lac- a consumer to feed the individual key values to.- Returns:
- false if the consumer provided ever returned false, true otherwise.
-
forEachLongRange
For as long as the consumer wants more ranges, call accept on the consumer with the individual key ranges in this OrderedKeys, in increasing order.- Parameters:
larc- a consumer to feed the individual key values to.- Returns:
- false if the consumer provided ever returned false, true otherwise.
-
forAllLongs
-
forAllLongRanges
-
close
default void close()Free any resources associated with this object.
Using any
OrderedKeysmethods afterclose()is an error and may produce exceptions or undefined results.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSafeCloseable
-
forRange
-