001package squidpony.squidmath;
002
003/**
004 * A group of similar methods for getting hashes of points based on long coordinates in 2, 3, 4, or 6 dimensions and
005 * a long for state. Internally, the methods here are based on a simplified version of Hive from {@link CrossHash};
006 * this version does not include the somewhat-involved finalization step. Omitting finalization helps this class be
007 * somewhat faster, but also makes it so it doesn't avalanche very well. Avalanche refers to the property of a hash
008 * where one changed bit in the input(s) or state has a chance to change any of the output's bits, and should
009 * usually change about 50% of them. You can call {@link #avalanche(long)} on the result of a hashAll() call to put
010 * the finalization step back. This has rather good quality when {@link #avalanche(long)} is used, but most usage
011 * will not be able to discern a difference between the quality of this (with or without avalanche) and the quality of
012 * {@link HastyPointHash}, where HastyPointHash is a fair amount faster. If your state and input are ints anyway,
013 * consider {@link IntPointHash}, since it's faster than the long-based hashes and still has perfectly fine quality.
014 * <br>
015 * This implements {@link IPointHash} and has a long it uses internally for state, exposed by {@link #getState()}.
016 */
017public final class PointHash extends IPointHash.LongImpl
018{
019    @Override
020    public int hashWithState(int x, int y, int state) {
021        return (int)hashAll(x, y, state);
022    }
023
024    @Override
025    public int hashWithState(int x, int y, int z, int state) {
026        return (int)hashAll(x, y, z, state);
027    }
028
029    @Override
030    public int hashWithState(int x, int y, int z, int w, int state) {
031        return (int)hashAll(x, y, z, w, state);
032    }
033
034    @Override
035    public int hashWithState(int x, int y, int z, int w, int u, int v, int state) {
036        return (int)hashAll(x, y, z, w, u, v, state);
037    }
038
039    public long getState(){
040        return state;
041    }
042
043    /**
044     * If it's important for some usage that one bit of change in any parameters cause roughly 50% of all bits in
045     * the result to change, then you can call this on the output of any hashAll() overload to improve the bit
046     * avalanche qualities.
047     * @param state the output of hashAll() in this class
048     * @return a significantly-mixed-around long obtained from state
049     */
050    public static long avalanche(long state)
051    {
052        state = (state ^ state >>> 33) * 0xFF51AFD7ED558CCDL;
053        return (state ^ state >>> 33) * 0xC4CEB9FE1A85EC53L;
054    }
055    /**
056     *
057     * @param x
058     * @param y
059     * @param state
060     * @return 64-bit hash of the x,y point with the given state
061     */
062    public static long hashAll(long x, long y, long state)
063    {
064        state *= 0x9E3779B97F4A7C15L;
065        long other = 0x60642E2A34326F15L;
066        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
067        state = (state << 54 | state >>> 10);
068        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
069        state -= ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL;
070        return state ^ state >>> 31;
071        
072//            return ((x = ((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26 ^ 0x9183A1F4F348E683L) * (
073//                    ((y = ((y *= 0x6C8E9CF570932BD5L) ^ y >>> 26 ^ 0x9183A1F4F348E683L) * (
074//                            state * 0x9E3779B97F4A7C15L 
075//                                    | 1L)) ^ y >>> 24) 
076//                            | 1L)) ^ x >>> 24);
077
078//            state = (state ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL | 1L;
079//            x *= state;
080//            y *= state;
081//            return state ^ (x << 26 | x >>> 38) + (y << 23 | y >>> 41);
082
083//        return ((x = ((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26 ^ 0x9183A1F4F348E683L) * (
084//                ((y = ((y *= 0x6C8E9CF570932BD5L) ^ y >>> 26 ^ 0x9183A1F4F348E683L) * (
085//                                        state * 0x9E3779B97F4A7C15L
086//                                | 1L)) ^ y >>> 24)
087//                        | 1L)) ^ x >>> 24);
088
089//            return (x = ((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L)) ^ x >>> 24
090//                    ^ (y = ((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state) ^ y >>> 24;
091//            return ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
092//                    ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31);
093        //state *= 0x352E9CF570932BDDL;
094//            return (((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((y ^ state) | 0xA529L)) ^ (state >>> 22)) ^
095//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((x ^ state) | 0xA529L)) ^ (state >>> 22)));
096    }
097
098    /**
099     *
100     * @param x
101     * @param y
102     * @param z
103     * @param state
104     * @return 64-bit hash of the x,y,z point with the given state
105     */
106    public static long hashAll(long x, long y, long z, long state)
107    {
108        state *= 0x9E3779B97F4A7C15L;
109        long other = 0x60642E2A34326F15L;
110        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
111        state = (state << 54 | state >>> 10);
112        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
113        state = (state << 54 | state >>> 10);
114        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
115        state -= ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL;
116        return state ^ state >>> 31;
117
118//            return (x = ((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L)) ^ x >>> 24
119//                    ^ (y = ((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state) ^ y >>> 24
120//                    ^ (z = ((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state) ^ z >>> 24;
121
122//            return ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
123//                    ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
124//                    ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
125//                    ;
126
127        //state *= 0x352E9CF570932BDDL;
128//            return (((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
129//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
130//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ x) | 0xA529L)) ^ (state >>> 22)));
131    }
132
133    /**
134     *
135     * @param x
136     * @param y
137     * @param z
138     * @param w
139     * @param state
140     * @return 64-bit hash of the x,y,z,w point with the given state
141     */
142    public static long hashAll(long x, long y, long z, long w, long state)
143    {
144        state *= 0x9E3779B97F4A7C15L;
145        long other = 0x60642E2A34326F15L;
146        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
147        state = (state << 54 | state >>> 10);
148        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
149        state = (state << 54 | state >>> 10);
150        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
151        state = (state << 54 | state >>> 10);
152        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
153        state -= ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL;
154        return state ^ state >>> 31;
155
156//            return (x = ((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L)) ^ x >>> 24
157//                    ^ (y = ((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state) ^ y >>> 24
158//                    ^ (z = ((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state) ^ z >>> 24
159//                    ^ (w = ((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state) ^ w >>> 24;
160
161//            return ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
162//                    ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
163//                    ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
164//                    ^ ((state = ((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
165//                    ;
166
167        //state *= 0x352E9CF570932BDDL;
168//            return (((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
169//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
170//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
171//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ w) ^ (state >>> 25)) * ((state ^ x) | 0xA529L)) ^ (state >>> 22)));
172    }
173
174    /**
175     *
176     * @param x
177     * @param y
178     * @param z
179     * @param w
180     * @param u
181     * @param v
182     * @param state
183     * @return 64-bit hash of the x,y,z,w,u,v point with the given state
184     */
185    public static long hashAll(long x, long y, long z, long w, long u, long v, long state)
186    {
187        state *= 0x9E3779B97F4A7C15L;
188        long other = 0x60642E2A34326F15L;
189        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
190        state = (state << 54 | state >>> 10);
191        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
192        state = (state << 54 | state >>> 10);
193        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
194        state = (state << 54 | state >>> 10);
195        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
196        state = (state << 54 | state >>> 10);
197        state ^= (other += (u ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
198        state = (state << 54 | state >>> 10);
199        state ^= (other += (v ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
200        state -= ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL;
201        return state ^ state >>> 31;
202
203//            return (x = ((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L)) ^ x >>> 24
204//                    ^ (y = ((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state) ^ y >>> 24
205//                    ^ (z = ((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state) ^ z >>> 24
206//                    ^ (w = ((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state) ^ w >>> 24
207//                    ^ (u = ((u *= 0xBF58476D1CE4E5B9L) ^ u >>> 26) * state) ^ u >>> 24
208//                    ^ (v = ((v *= 0xC6BC279692B5CC85L) ^ v >>> 26) * state) ^ v >>> 24;
209
210//            return ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
211//                    ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
212//                    ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
213//                    ^ ((state = ((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ u) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
214//                    ^ ((state = ((state = u ^ ((state += 0x9E3779B97F4A7C15L ^ v) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
215//                    ^ ((state = ((state = v ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL) ^ state >>> 31)
216//                    ;
217
218        //state *= 0x352E9CF570932BDDL;
219//            return (((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
220//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
221//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
222//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ w) ^ (state >>> 25)) * ((state ^ u) | 0xA529L)) ^ (state >>> 22)) ^
223//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ u) ^ (state >>> 25)) * ((state ^ v) | 0xA529L)) ^ (state >>> 22)) ^
224//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ v) ^ (state >>> 25)) * ((state ^ x) | 0xA529L)) ^ (state >>> 22)));
225    }
226    /**
227     *
228     * @param x
229     * @param y
230     * @param state
231     * @return 8-bit hash of the x,y point with the given state
232     */         
233    public static int hash256(long x, long y, long state) {
234        state *= 0x9E3779B97F4A7C15L;
235        long other = 0x60642E2A34326F15L;
236        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
237        state = (state << 54 | state >>> 10);
238        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
239        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 56);
240
241//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
242//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)) >>> 56);
243
244//                return (int) ((
245//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
246//                    ^ ((((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
247//            ) >>> 56);
248
249        //state *= 0x352E9CF570932BDDL;
250//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((y ^ state) | 0xA529L)) ^ (state >>> 22)) ^
251//                    (((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((x ^ state) | 0xA529L))) >>> 56);
252    }
253    /**
254     *
255     * @param x
256     * @param y
257     * @param z
258     * @param state
259     * @return 8-bit hash of the x,y,z point with the given state
260     */
261    public static int hash256(long x, long y, long z, long state)
262    {
263        state *= 0x9E3779B97F4A7C15L;
264        long other = 0x60642E2A34326F15L;
265        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
266        state = (state << 54 | state >>> 10);
267        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
268        state = (state << 54 | state >>> 10);
269        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
270        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 56);
271
272//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
273//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
274//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
275//            ) >>> 56);
276
277//            return (int) ((
278//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
279//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
280//                            ^ ((((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
281//            ) >>> 56);
282
283        //state *= 0x352E9CF570932BDDL;
284//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
285//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
286//                    (((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 56);
287    }
288    /**
289     *
290     * @param x
291     * @param y
292     * @param z
293     * @param w
294     * @param state
295     * @return 8-bit hash of the x,y,z,w point with the given state
296     */
297    public static int hash256(long x, long y, long z, long w, long state)
298    {
299        state *= 0x9E3779B97F4A7C15L;
300        long other = 0x60642E2A34326F15L;
301        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
302        state = (state << 54 | state >>> 10);
303        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
304        state = (state << 54 | state >>> 10);
305        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
306        state = (state << 54 | state >>> 10);
307        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
308        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 56);
309
310//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
311//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
312//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
313//                    ^ (((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state)
314//            ) >>> 56);
315
316//            return (int) ((
317//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
318//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
319//                            ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
320//                            ^ ((((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
321        //state *= 0x352E9CF570932BDDL;
322//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
323//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
324//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
325//                    (((state += 0x6C8E9CD570932BD5L ^ w) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 56);
326    }
327    /**
328     *
329     * @param x
330     * @param y
331     * @param z
332     * @param w
333     * @param u
334     * @param v
335     * @param state
336     * @return 8-bit hash of the x,y,z,w,u,v point with the given state
337     */
338    public static int hash256(long x, long y, long z, long w, long u, long v, long state)
339    {
340        state *= 0x9E3779B97F4A7C15L;
341        long other = 0x60642E2A34326F15L;
342        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
343        state = (state << 54 | state >>> 10);
344        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
345        state = (state << 54 | state >>> 10);
346        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
347        state = (state << 54 | state >>> 10);
348        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
349        state = (state << 54 | state >>> 10);
350        state ^= (other += (u ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
351        state = (state << 54 | state >>> 10);
352        state ^= (other += (v ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
353        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 56);
354
355//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
356//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
357//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
358//                    ^ (((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state)
359//                    ^ (((u *= 0xBF58476D1CE4E5B9L) ^ u >>> 26) * state)
360//                    ^ (((v *= 0xC6BC279692B5CC85L) ^ v >>> 26) * state)
361//            ) >>> 56);
362
363//            return (int) ((
364//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
365//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
366//                            ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
367//                            ^ ((state = ((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ u) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
368//                            ^ ((state = ((state = u ^ ((state += 0x9E3779B97F4A7C15L ^ v) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
369//                            ^ ((((state = v ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
370//            ) >>> 56);
371
372        //state *= 0x352E9CF570932BDDL;
373//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
374//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
375//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
376//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
377//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ u) ^ (state >>> 25)) * ((state ^ v) | 0xA529L)) ^ (state >>> 22)) ^
378//                    (((state += 0x6C8E9CD570932BD5L ^ v) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 56);
379    }
380    /**
381     *
382     * @param x
383     * @param y
384     * @param state
385     * @return 5-bit hash of the x,y point with the given state
386     */
387    public static int hash32(long x, long y, long state)
388    {
389        state *= 0x9E3779B97F4A7C15L;
390        long other = 0x60642E2A34326F15L;
391        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
392        state = (state << 54 | state >>> 10);
393        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
394        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 59);
395        
396//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
397//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
398//            ) >>> 59);
399
400//            return (int) ((
401//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
402//                            ^ ((((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
403//            ) >>> 59);
404
405        //state *= 0x352E9CF570932BDDL;
406//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
407//                    (((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 59);
408    }
409    /**
410     *
411     * @param x
412     * @param y
413     * @param z
414     * @param state
415     * @return 5-bit hash of the x,y,z point with the given state
416     */
417    public static int hash32(long x, long y, long z, long state)
418    {
419        state *= 0x9E3779B97F4A7C15L;
420        long other = 0x60642E2A34326F15L;
421        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
422        state = (state << 54 | state >>> 10);
423        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
424        state = (state << 54 | state >>> 10);
425        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
426        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 59);
427
428//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
429//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
430//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
431//            ) >>> 59);
432
433//            return (int) ((
434//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
435//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
436//                            ^ ((((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
437//            ) >>> 59);
438
439        //state *= 0x352E9CF570932BDDL;
440//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y - z) | 0xA529L)) ^ (state >>> 22)) ^
441//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z - x) | 0xA529L)) ^ (state >>> 22)) ^
442//                    (((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ x - y) | 0xA529L))) >>> 59);
443    }
444    /**
445     *
446     * @param x
447     * @param y
448     * @param z
449     * @param w
450     * @param state
451     * @return 5-bit hash of the x,y,z,w point with the given state
452     */
453    public static int hash32(long x, long y, long z, long w, long state)
454    {
455        state *= 0x9E3779B97F4A7C15L;
456        long other = 0x60642E2A34326F15L;
457        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
458        state = (state << 54 | state >>> 10);
459        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
460        state = (state << 54 | state >>> 10);
461        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
462        state = (state << 54 | state >>> 10);
463        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
464        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 59);
465
466//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
467//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
468//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
469//                    ^ (((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state)
470//            ) >>> 59);
471
472//            return (int) ((
473//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
474//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
475//                            ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
476//                            ^ ((((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
477//            ) >>> 59);
478
479        //state *= 0x352E9CF570932BDDL;
480//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
481//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
482//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
483//                    (((state += 0x6C8E9CD570932BD5L ^ w) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 59);
484    }
485    /**
486     *
487     * @param x
488     * @param y
489     * @param z
490     * @param w
491     * @param u
492     * @param v
493     * @param state
494     * @return 5-bit hash of the x,y,z,w,u,v point with the given state
495     */
496    public static int hash32(long x, long y, long z, long w, long u, long v, long state)
497    {
498        state *= 0x9E3779B97F4A7C15L;
499        long other = 0x60642E2A34326F15L;
500        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
501        state = (state << 54 | state >>> 10);
502        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
503        state = (state << 54 | state >>> 10);
504        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
505        state = (state << 54 | state >>> 10);
506        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
507        state = (state << 54 | state >>> 10);
508        state ^= (other += (u ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
509        state = (state << 54 | state >>> 10);
510        state ^= (other += (v ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
511        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 59);
512
513//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
514//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
515//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
516//                    ^ (((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state)
517//                    ^ (((u *= 0xBF58476D1CE4E5B9L) ^ u >>> 26) * state)
518//                    ^ (((v *= 0xC6BC279692B5CC85L) ^ v >>> 26) * state)
519//            ) >>> 59);
520
521//            return (int) ((
522//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
523//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
524//                            ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
525//                            ^ ((state = ((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ u) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
526//                            ^ ((state = ((state = u ^ ((state += 0x9E3779B97F4A7C15L ^ v) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
527//                            ^ ((((state = v ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
528//            ) >>> 59);
529
530        //state *= 0x352E9CF570932BDDL;
531//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
532//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
533//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
534//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
535//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ u) ^ (state >>> 25)) * ((state ^ v) | 0xA529L)) ^ (state >>> 22)) ^
536//                    (((state += 0x6C8E9CD570932BD5L ^ v) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 59);
537    }
538
539    /**
540     *
541     * @param x
542     * @param y
543     * @param state
544     * @return 6-bit hash of the x,y point with the given state
545     */
546    public static int hash64(long x, long y, long state)
547    {
548        state *= 0x9E3779B97F4A7C15L;
549        long other = 0x60642E2A34326F15L;
550        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
551        state = (state << 54 | state >>> 10);
552        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
553        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 58);
554
555//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
556//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
557//            ) >>> 58);
558
559//            return (int) ((
560//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
561//                            ^ ((((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
562//            ) >>> 58);
563
564
565        //state *= 0x352E9CF570932BDDL;
566//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
567//                    (((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 58);
568    }
569    /**
570     *
571     * @param x
572     * @param y
573     * @param z
574     * @param state
575     * @return 6-bit hash of the x,y,z point with the given state
576     */
577    public static int hash64(long x, long y, long z, long state)
578    {
579        state *= 0x9E3779B97F4A7C15L;
580        long other = 0x60642E2A34326F15L;
581        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
582        state = (state << 54 | state >>> 10);
583        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
584        state = (state << 54 | state >>> 10);
585        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
586        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 58);
587
588//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
589//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
590//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
591//            ) >>> 58);
592
593//            return (int) ((
594//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
595//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
596//                            ^ ((((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
597//            ) >>> 58);
598
599        //state *= 0x352E9CF570932BDDL;
600//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y - z) | 0xA529L)) ^ (state >>> 22)) ^
601//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z - x) | 0xA529L)) ^ (state >>> 22)) ^
602//                    (((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ x - y) | 0xA529L))) >>> 58);
603    }
604    /**
605     *
606     * @param x
607     * @param y
608     * @param z
609     * @param w
610     * @param state
611     * @return 6-bit hash of the x,y,z,w point with the given state
612     */
613    public static int hash64(long x, long y, long z, long w, long state)
614    {
615        state *= 0x9E3779B97F4A7C15L;
616        long other = 0x60642E2A34326F15L;
617        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
618        state = (state << 54 | state >>> 10);
619        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
620        state = (state << 54 | state >>> 10);
621        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
622        state = (state << 54 | state >>> 10);
623        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
624        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 58);
625
626//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
627//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
628//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
629//                    ^ (((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state)
630//            ) >>> 58);
631
632//            return (int) ((
633//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
634//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
635//                            ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
636//                            ^ ((((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
637//            ) >>> 58);
638
639        //state *= 0x352E9CF570932BDDL;
640//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
641//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
642//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
643//                    (((state += 0x6C8E9CD570932BD5L ^ w) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 58);
644    }
645    /**
646     *
647     * @param x
648     * @param y
649     * @param z
650     * @param w
651     * @param u
652     * @param v
653     * @param state
654     * @return 6-bit hash of the x,y,z,w,u,v point with the given state
655     */
656    public static int hash64(long x, long y, long z, long w, long u, long v, long state)
657    {
658        state *= 0x9E3779B97F4A7C15L;
659        long other = 0x60642E2A34326F15L;
660        state ^= (other += (x ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
661        state = (state << 54 | state >>> 10);
662        state ^= (other += (y ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
663        state = (state << 54 | state >>> 10);
664        state ^= (other += (z ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
665        state = (state << 54 | state >>> 10);
666        state ^= (other += (w ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
667        state = (state << 54 | state >>> 10);
668        state ^= (other += (u ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
669        state = (state << 54 | state >>> 10);
670        state ^= (other += (v ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL);
671        return (int)(state - ((state << 54 | state >>> 10) + (other ^ other >>> 29)) * 0x94D049BB133111EBL >>> 58);
672
673//            return (int) (((((x *= 0x6C8E9CF570932BD5L) ^ x >>> 26) * (state = state * 0x9E3779B97F4A7C15L | 1L))
674//                    ^ (((y *= 0x5851F42D4C957F2DL) ^ y >>> 26) * state)
675//                    ^ (((z *= 0xAEF17502108EF2D9L) ^ z >>> 26) * state)
676//                    ^ (((w *= 0x94D049BB133111EBL) ^ w >>> 26) * state)
677//                    ^ (((u *= 0xBF58476D1CE4E5B9L) ^ u >>> 26) * state)
678//                    ^ (((v *= 0xC6BC279692B5CC85L) ^ v >>> 26) * state)
679//            ) >>> 58);
680
681//            return (int) ((
682//                    ((state = ((state = x ^ ((state += 0x9E3779B97F4A7C15L ^ y) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
683//                            ^ ((state = ((state = y ^ ((state += 0x9E3779B97F4A7C15L ^ z) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
684//                            ^ ((state = ((state = z ^ ((state += 0x9E3779B97F4A7C15L ^ w) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
685//                            ^ ((state = ((state = w ^ ((state += 0x9E3779B97F4A7C15L ^ u) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
686//                            ^ ((state = ((state = u ^ ((state += 0x9E3779B97F4A7C15L ^ v) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
687//                            ^ ((((state = v ^ ((state += 0x9E3779B97F4A7C15L ^ x) ^ state >>> 30) * 0xBF58476D1CE4E5B9L) ^ state >>> 27) * 0x94D049BB133111EBL))
688//            ) >>> 58);
689
690        //state *= 0x352E9CF570932BDDL;
691//            return (int) ((((state = ((state += 0x6C8E9CD570932BD5L ^ x) ^ (state >>> 25)) * ((state ^ y) | 0xA529L)) ^ (state >>> 22)) ^
692//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ y) ^ (state >>> 25)) * ((state ^ z) | 0xA529L)) ^ (state >>> 22)) ^
693//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
694//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ z) ^ (state >>> 25)) * ((state ^ w) | 0xA529L)) ^ (state >>> 22)) ^
695//                    ((state = ((state += 0x6C8E9CD570932BD5L ^ u) ^ (state >>> 25)) * ((state ^ v) | 0xA529L)) ^ (state >>> 22)) ^
696//                    (((state += 0x6C8E9CD570932BD5L ^ v) ^ (state >>> 25)) * ((state ^ x) | 0xA529L))) >>> 58);
697    }
698
699}