Class UnsignedIntEncoder

java.lang.Object
io.permazen.util.UnsignedIntEncoder

public final class UnsignedIntEncoder extends Object
Encodes unsigned (i.e., non-negative) int values to/from self-delimited binary, preserving sort order, and such that the length of the encoding is optimized for values near zero and encoded values never begin with 0xff.

The encoding uses a simple prefixing format:

Encoding Format
Encoded Bytes Value
0x00 ... 0xfa Same
0xfb 0xWW 0xWW + 0xfb
0xfc 0xWW 0xXX 0xWWXX + 0xfb
0xfd 0xWW 0xXX 0xYY 0xWWXXYY + 0xfb
0xfe 0xWW 0xXX 0xYY 0xZZ 0xWWXXYYZZ + 0xfb
0xff Illegal