package electrosphere.util.math;

/**
 * Utilities for hashing things
 */
public class HashUtils {

    private static final int SHIFT_Y = 16; // 16 bits per value
    private static final int SHIFT_Z = 32; // 2 * 16 bits
    
    /**
     * Hashes an integer vector. Must be within the range [0,65536]
     * @param x The x component
     * @param y The y component
     * @param z The z component
     * @return The hashed value
     */
    public static long hashIVec(int x, int y, int z){
        if (x < 0 || x > 65536 || y < 0 || y > 65536 || z < 0 || z > 65536) {
            throw new IllegalArgumentException("Values must be in range [0, 65536]");
        }
        return ((long) x) | ((long) y << SHIFT_Y) | ((long) z << SHIFT_Z);
    }

}
