public interface BitOut extends Closeable
Modifier and Type | Method and Description |
---|---|
byte |
getBitOffset()
Returns the bit offset in the last byte.
|
long |
getByteOffset()
Returns the byte offset of the stream.
|
int |
writeBinary(int len,
int x)
Writes an integer in binary format to the stream.
|
int |
writeDelta(int x)
Writes an integer x into the stream using delta encoding.
|
int |
writeGamma(int x)
Writes an integer x into the stream using gamma encoding.
|
int |
writeGolomb(int x,
int b)
Writes and integer x into the stream using golomb coding.
|
int |
writeInt(int x,
int len)
Writes an integer x into the underlying OutputStream.
|
int |
writeInterpolativeCode(int[] data,
int offset,
int len,
int lo,
int hi)
Writes a sequence of integers using interpolative coding.
|
int |
writeMinimalBinary(int x,
int b)
Writes an integer x using minimal binary encoding, given an upper bound.
|
int |
writeSkewedGolomb(int x,
int b)
Writes and integer x into the stream using skewed-golomb coding.
|
int |
writeUnary(int x)
Writes an integer x using unary encoding.
|
long getByteOffset()
byte getBitOffset()
int writeUnary(int x) throws IOException
x
- the number to writeIOException
- if an I/O error occurs.int writeGamma(int x) throws IOException
x
- the int number to writeIOException
- if an I/O error occurs.int writeBinary(int len, int x) throws IOException
len
- size in bits of the number.x
- the integer to write.IOException
- if an I/O error occurs.int writeInterpolativeCode(int[] data, int offset, int len, int lo, int hi) throws IOException
data
- the vector containing the integer sequence.offset
- the offset into data
where the sequence starts.len
- the number of integers to code.lo
- a lower bound (must be smaller than or equal to the first integer in the sequence).hi
- an upper bound (must be greater than or equal to the last integer in the sequence).IOException
- if an I/O error occurs.int writeSkewedGolomb(int x, int b) throws IOException
v = <b, 2b, 4b, ... , 2^i b, ...>
an integer x
is coded as unary(k+1)
where k
is the index
sum(i=0)(k) v_i < x <= sum(i=0)(k+1)
k = log(x/b + 1)
sum_i = b(2^n -1)
(geometric progression)
and the remainder with log(v_k)
bits in binary
if lower = ceil(x/b) -> lower = 2^i * b -> i = log(ceil(x/b)) + 1
the remainder x - sum_i 2^i*b - 1 = x - b(2^n - 1) - 1
is coded with floor(log(v_k))
bits
This method is not failsafe, it doesn't check if the argument or the modulus is 0 or negative.x
- the number to writeb
- the parameter for golomb codingIOException
- if and I/O error occursint writeGolomb(int x, int b) throws IOException
x
- the number to writeb
- the parameter for golomb codingIOException
- if and I/O error occursint writeMinimalBinary(int x, int b) throws IOException
x
- the number to writeb
- and strict bound for x
IOException
- if an I/O error occurs.int writeDelta(int x) throws IOException
x
- the int number to writeIOException
- if an I/O error occurs.int writeInt(int x, int len) throws IOException
x
- the int to writelen
- length of the int in bitsIOException
- if an I/O error occurs.Terrier Information Retrieval Platform4.1. Copyright © 2004-2015, University of Glasgow