IndexCompressor

interface IndexCompressor

This interface defines the abstract protocol for compressing a sequence of integers used by the Serializer and Deserializer.

Inheritors

Functions

Link copied to clipboard
abstract fun compress(index: Int): Int

Given an index to serialize, or one that was reconstructed during deserialization, update this compressor to take this index into account, and answer an encoding that the deserializer will be able to use to get back to the original index, given a compressor in the same state.

Link copied to clipboard
abstract fun currentIndex(): Int

The current index number, which is one more than the last value returned by incrementIndex.

Link copied to clipboard
abstract fun decompress(index: Int): Int

Given an encoded index that was produced by compress from the same state that the compressor is now in, answer the original Int that was provided to compress to get the encoded Int. Also ensure the compressor is updated in the exact same way that the original compress call would have done.

Link copied to clipboard
abstract fun incrementIndex()

Advance the current index number. This value can be tracked by subclasses to support current-index-relative (backward) offsets.