Hashing.java 7.97 KB
package com.google.common.hash;

import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import java.util.Iterator;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
import javax.annotation.Nullable;
import qr;
import qv;
import qw;
import qx;
import qy;
import qz;

@Beta
public final class Hashing
{
  private static final int a = (int)System.currentTimeMillis();
  
  public static HashFunction adler32()
  {
    return a.a;
  }
  
  public static HashCode combineOrdered(Iterable<HashCode> paramIterable)
  {
    Object localObject = paramIterable.iterator();
    Preconditions.checkArgument(((Iterator)localObject).hasNext(), "Must be at least 1 hash code to combine.");
    localObject = new byte[((HashCode)((Iterator)localObject).next()).bits() / 8];
    paramIterable = paramIterable.iterator();
    if (paramIterable.hasNext())
    {
      byte[] arrayOfByte = ((HashCode)paramIterable.next()).asBytes();
      if (arrayOfByte.length == localObject.length) {}
      for (boolean bool = true;; bool = false)
      {
        Preconditions.checkArgument(bool, "All hashcodes must have the same bit length.");
        int i = 0;
        while (i < arrayOfByte.length)
        {
          localObject[i] = ((byte)(localObject[i] * 37 ^ arrayOfByte[i]));
          i += 1;
        }
        break;
      }
    }
    return HashCode.a((byte[])localObject);
  }
  
  public static HashCode combineUnordered(Iterable<HashCode> paramIterable)
  {
    Object localObject = paramIterable.iterator();
    Preconditions.checkArgument(((Iterator)localObject).hasNext(), "Must be at least 1 hash code to combine.");
    localObject = new byte[((HashCode)((Iterator)localObject).next()).bits() / 8];
    paramIterable = paramIterable.iterator();
    if (paramIterable.hasNext())
    {
      byte[] arrayOfByte = ((HashCode)paramIterable.next()).asBytes();
      if (arrayOfByte.length == localObject.length) {}
      for (boolean bool = true;; bool = false)
      {
        Preconditions.checkArgument(bool, "All hashcodes must have the same bit length.");
        int i = 0;
        while (i < arrayOfByte.length)
        {
          localObject[i] = ((byte)(localObject[i] + arrayOfByte[i]));
          i += 1;
        }
        break;
      }
    }
    return HashCode.a((byte[])localObject);
  }
  
  public static int consistentHash(long paramLong, int paramInt)
  {
    int i = 0;
    if (paramInt > 0) {}
    for (boolean bool = true;; bool = false)
    {
      Preconditions.checkArgument(bool, "buckets must be positive: %s", new Object[] { Integer.valueOf(paramInt) });
      f localf = new f(paramLong);
      for (;;)
      {
        double d = i + 1;
        localf.a = (2862933555777941757L * localf.a + 1L);
        int j = (int)(d / (((int)(localf.a >>> 33) + 1) / 2.147483648E9D));
        if ((j < 0) || (j >= paramInt)) {
          break;
        }
        i = j;
      }
    }
    return i;
  }
  
  public static int consistentHash(HashCode paramHashCode, int paramInt)
  {
    return consistentHash(paramHashCode.padToLong(), paramInt);
  }
  
  public static HashFunction crc32()
  {
    return d.a;
  }
  
  public static HashFunction crc32c()
  {
    return e.a;
  }
  
  public static HashFunction goodFastHash(int paramInt)
  {
    int i = 1;
    if (paramInt > 0) {}
    for (boolean bool = true;; bool = false)
    {
      Preconditions.checkArgument(bool, "Number of bits must be positive");
      paramInt = paramInt + 31 & 0xFFFFFFE0;
      if (paramInt != 32) {
        break;
      }
      return i.b;
    }
    if (paramInt <= 128) {
      return h.b;
    }
    int k = (paramInt + 127) / 128;
    HashFunction[] arrayOfHashFunction = new HashFunction[k];
    arrayOfHashFunction[0] = h.b;
    int j = a;
    paramInt = i;
    i = j;
    while (paramInt < k)
    {
      i += 1500450271;
      arrayOfHashFunction[paramInt] = murmur3_128(i);
      paramInt += 1;
    }
    return new c(arrayOfHashFunction);
  }
  
  public static HashFunction md5()
  {
    return g.a;
  }
  
  public static HashFunction murmur3_128()
  {
    return h.a;
  }
  
  public static HashFunction murmur3_128(int paramInt)
  {
    return new qx(paramInt);
  }
  
  public static HashFunction murmur3_32()
  {
    return i.a;
  }
  
  public static HashFunction murmur3_32(int paramInt)
  {
    return new qy(paramInt);
  }
  
  public static HashFunction sha1()
  {
    return j.a;
  }
  
  public static HashFunction sha256()
  {
    return k.a;
  }
  
  public static HashFunction sha512()
  {
    return l.a;
  }
  
  public static HashFunction sipHash24()
  {
    return m.a;
  }
  
  public static HashFunction sipHash24(long paramLong1, long paramLong2)
  {
    return new qz(paramLong1, paramLong2);
  }
  
  static final class a
  {
    static final HashFunction a = Hashing.a(Hashing.b.b, "Hashing.adler32()");
  }
  
  static abstract enum b
    implements Supplier<Checksum>
  {
    private final int c = 32;
    
    private b(int paramInt) {}
    
    public abstract Checksum a();
  }
  
  @VisibleForTesting
  static final class c
    extends qr
  {
    private final int b;
    
    c(HashFunction... paramVarArgs)
    {
      super();
      int k = paramVarArgs.length;
      int j = 0;
      while (i < k)
      {
        j += paramVarArgs[i].bits();
        i += 1;
      }
      this.b = j;
    }
    
    final HashCode a(Hasher[] paramArrayOfHasher)
    {
      int i = 0;
      byte[] arrayOfByte = new byte[this.b / 8];
      int k = paramArrayOfHasher.length;
      int j = 0;
      while (i < k)
      {
        HashCode localHashCode = paramArrayOfHasher[i].hash();
        j += localHashCode.writeBytesTo(arrayOfByte, j, localHashCode.bits() / 8);
        i += 1;
      }
      return HashCode.a(arrayOfByte);
    }
    
    public final int bits()
    {
      return this.b;
    }
    
    public final boolean equals(@Nullable Object paramObject)
    {
      if ((paramObject instanceof c))
      {
        paramObject = (c)paramObject;
        if ((this.b == ((c)paramObject).b) && (this.a.length == ((c)paramObject).a.length)) {}
      }
      else
      {
        return false;
      }
      int i = 0;
      for (;;)
      {
        if (i >= this.a.length) {
          break label74;
        }
        if (!this.a[i].equals(paramObject.a[i])) {
          break;
        }
        i += 1;
      }
      label74:
      return true;
    }
    
    public final int hashCode()
    {
      int j = this.b;
      HashFunction[] arrayOfHashFunction = this.a;
      int k = arrayOfHashFunction.length;
      int i = 0;
      while (i < k)
      {
        j ^= arrayOfHashFunction[i].hashCode();
        i += 1;
      }
      return j;
    }
  }
  
  static final class d
  {
    static final HashFunction a = Hashing.a(Hashing.b.a, "Hashing.crc32()");
  }
  
  static final class e
  {
    static final HashFunction a = new qv();
  }
  
  static final class f
  {
    long a;
    
    public f(long paramLong)
    {
      this.a = paramLong;
    }
  }
  
  static final class g
  {
    static final HashFunction a = new qw("MD5", "Hashing.md5()");
  }
  
  static final class h
  {
    static final HashFunction a = new qx(0);
    static final HashFunction b = Hashing.murmur3_128(Hashing.a());
  }
  
  static final class i
  {
    static final HashFunction a = new qy(0);
    static final HashFunction b = Hashing.murmur3_32(Hashing.a());
  }
  
  static final class j
  {
    static final HashFunction a = new qw("SHA-1", "Hashing.sha1()");
  }
  
  static final class k
  {
    static final HashFunction a = new qw("SHA-256", "Hashing.sha256()");
  }
  
  static final class l
  {
    static final HashFunction a = new qw("SHA-512", "Hashing.sha512()");
  }
  
  static final class m
  {
    static final HashFunction a = new qz(506097522914230528L, 1084818905618843912L);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/hash/Hashing.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */