Reformat whole codebase using Android Studio
This commit is contained in:
parent
d5322667d5
commit
c15913c1ab
161 changed files with 15124 additions and 18537 deletions
|
|
@ -10,8 +10,7 @@ import java.io.IOException;
|
|||
import java.io.OutputStream;
|
||||
|
||||
|
||||
public final class MixCoderDataOutputStream extends DataOutputStream
|
||||
{
|
||||
public final class MixCoderDataOutputStream extends DataOutputStream {
|
||||
private int lastValue;
|
||||
private int lastLastValue;
|
||||
private int repCount;
|
||||
|
|
@ -23,28 +22,24 @@ public final class MixCoderDataOutputStream extends DataOutputStream
|
|||
public static int[] diffs = new int[100];
|
||||
public static int[] counts = new int[100];
|
||||
|
||||
public MixCoderDataOutputStream( OutputStream os )
|
||||
{
|
||||
super( os );
|
||||
public MixCoderDataOutputStream(OutputStream os) {
|
||||
super(os);
|
||||
}
|
||||
|
||||
public void writeMixed( int v ) throws IOException
|
||||
{
|
||||
if ( v != lastValue && repCount > 0 )
|
||||
{
|
||||
public void writeMixed(int v) throws IOException {
|
||||
if (v != lastValue && repCount > 0) {
|
||||
int d = lastValue - lastLastValue;
|
||||
lastLastValue = lastValue;
|
||||
|
||||
encodeBit( d < 0 );
|
||||
if ( d < 0 )
|
||||
{
|
||||
|
||||
encodeBit(d < 0);
|
||||
if (d < 0) {
|
||||
d = -d;
|
||||
}
|
||||
encodeVarBits( d-diffshift );
|
||||
encodeVarBits( repCount-1 );
|
||||
|
||||
if ( d < 100 ) diffs[d]++;
|
||||
if ( repCount < 100 ) counts[repCount]++;
|
||||
encodeVarBits(d - diffshift);
|
||||
encodeVarBits(repCount - 1);
|
||||
|
||||
if (d < 100) diffs[d]++;
|
||||
if (repCount < 100) counts[repCount]++;
|
||||
|
||||
diffshift = 1;
|
||||
repCount = 0;
|
||||
|
|
@ -54,59 +49,48 @@ public final class MixCoderDataOutputStream extends DataOutputStream
|
|||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException
|
||||
{
|
||||
public void flush() throws IOException {
|
||||
int v = lastValue;
|
||||
writeMixed( v+1 );
|
||||
writeMixed(v + 1);
|
||||
lastValue = v;
|
||||
repCount = 0;
|
||||
if ( bm > 1 )
|
||||
{
|
||||
writeByte( (byte)b ); // flush bit-coding
|
||||
if (bm > 1) {
|
||||
writeByte((byte) b); // flush bit-coding
|
||||
}
|
||||
}
|
||||
|
||||
public final void encodeBit( boolean value ) throws IOException
|
||||
{
|
||||
if ( bm == 0x100 )
|
||||
{
|
||||
writeByte( (byte)b );
|
||||
public final void encodeBit(boolean value) throws IOException {
|
||||
if (bm == 0x100) {
|
||||
writeByte((byte) b);
|
||||
bm = 1;
|
||||
b = 0;
|
||||
}
|
||||
if ( value )
|
||||
{
|
||||
if (value) {
|
||||
b |= bm;
|
||||
}
|
||||
bm <<= 1;
|
||||
}
|
||||
|
||||
public final void encodeVarBits( int value ) throws IOException
|
||||
{
|
||||
public final void encodeVarBits(int value) throws IOException {
|
||||
int range = 0;
|
||||
while (value > range)
|
||||
{
|
||||
encodeBit( false );
|
||||
while (value > range) {
|
||||
encodeBit(false);
|
||||
value -= range + 1;
|
||||
range = 2 * range + 1;
|
||||
}
|
||||
encodeBit( true );
|
||||
encodeBounded( range, value );
|
||||
encodeBit(true);
|
||||
encodeBounded(range, value);
|
||||
}
|
||||
|
||||
public final void encodeBounded( int max, int value ) throws IOException
|
||||
{
|
||||
public final void encodeBounded(int max, int value) throws IOException {
|
||||
int im = 1; // integer mask
|
||||
while (im <= max)
|
||||
{
|
||||
if ( bm == 0x100 )
|
||||
{
|
||||
writeByte( (byte)b );
|
||||
while (im <= max) {
|
||||
if (bm == 0x100) {
|
||||
writeByte((byte) b);
|
||||
bm = 1;
|
||||
b = 0;
|
||||
}
|
||||
if ( ( value & im ) != 0 )
|
||||
{
|
||||
if ((value & im) != 0) {
|
||||
b |= bm;
|
||||
max -= im;
|
||||
}
|
||||
|
|
@ -115,9 +99,8 @@ public final class MixCoderDataOutputStream extends DataOutputStream
|
|||
}
|
||||
}
|
||||
|
||||
public static void stats()
|
||||
{
|
||||
for(int i=1; i<100;i++) System.out.println( "diff[" + i + "] = " + diffs[i] );
|
||||
for(int i=1; i<100;i++) System.out.println( "counts[" + i + "] = " + counts[i] );
|
||||
public static void stats() {
|
||||
for (int i = 1; i < 100; i++) System.out.println("diff[" + i + "] = " + diffs[i]);
|
||||
for (int i = 1; i < 100; i++) System.out.println("counts[" + i + "] = " + counts[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue