65 lines
1.7 KiB
Java
65 lines
1.7 KiB
Java
package com.google.common.hash;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.ByteOrder;
|
|
|
|
/* loaded from: classes.dex */
|
|
abstract class AbstractStreamingHashFunction implements HashFunction {
|
|
|
|
protected static abstract class AbstractStreamingHasher extends AbstractHasher {
|
|
private final ByteBuffer a;
|
|
private final int b;
|
|
|
|
protected AbstractStreamingHasher(int i) {
|
|
this(i, i);
|
|
}
|
|
|
|
private void c() {
|
|
this.a.flip();
|
|
while (this.a.remaining() >= this.b) {
|
|
a(this.a);
|
|
}
|
|
this.a.compact();
|
|
}
|
|
|
|
@Override // com.google.common.hash.Hasher
|
|
public final <T> Hasher a(T t, Funnel<? super T> funnel) {
|
|
funnel.funnel(t, this);
|
|
return this;
|
|
}
|
|
|
|
protected abstract void a(ByteBuffer byteBuffer);
|
|
|
|
abstract HashCode b();
|
|
|
|
protected abstract void b(ByteBuffer byteBuffer);
|
|
|
|
protected AbstractStreamingHasher(int i, int i2) {
|
|
Preconditions.a(i2 % i == 0);
|
|
this.a = ByteBuffer.allocate(i2 + 7).order(ByteOrder.LITTLE_ENDIAN);
|
|
this.b = i;
|
|
}
|
|
|
|
@Override // com.google.common.hash.Hasher
|
|
public final HashCode a() {
|
|
c();
|
|
this.a.flip();
|
|
if (this.a.remaining() > 0) {
|
|
b(this.a);
|
|
}
|
|
return b();
|
|
}
|
|
}
|
|
|
|
AbstractStreamingHashFunction() {
|
|
}
|
|
|
|
@Override // com.google.common.hash.HashFunction
|
|
public <T> HashCode a(T t, Funnel<? super T> funnel) {
|
|
Hasher a = a();
|
|
a.a(t, funnel);
|
|
return a.a();
|
|
}
|
|
}
|