Java Utililty Methods Type Size

List of utility methods to do Type Size

Description

The list of methods to do Type Size are organized into topic(s).

Method

intsizeOfVarint(int value)
Number of bytes needed to encode an integer in variable-length format.
int v = (value << 1) ^ (value >> 31);
int bytes = 1;
while ((v & 0xffffff80) != 0L) {
    bytes += 1;
    v >>>= 7;
return bytes;
intsizeOfWriteLength(int len)
size Of Write Length
if (len < 0) {
    throw new RuntimeException("Invalid length < 0");
if (len <= 127) {
    return 1;
} else if (len <= 16383) {
    return 2;
} else if (len <= 2097151) {
...