public void Combine() { int h1 = Hashing.CombineInline(1991, 13); int h2 = Hashing.CombineInline(1991, 12); Assert.NotEqual(h1, h2); }
internal static uint CalculateHashForBits(BitVector vector, Hashing.Iterative.XXHash32Block state, int length = int.MaxValue, int lcp = int.MaxValue) { length = Math.Min(vector.Count, length); // Ensure we use the proper value. int words = length / BitVector.BitsPerWord; int remaining = length % BitVector.BitsPerWord; ulong remainingWord = 0; int shift = 0; if (remaining != 0) { remainingWord = vector.GetWord(words); // Zero addressing ensures we get the next byte. shift = BitVector.BitsPerWord - remaining; } unsafe { fixed(ulong *bitsPtr = vector.Bits) { uint hash = Hashing.Iterative.XXHash32.CalculateInline((byte *)bitsPtr, words * sizeof(ulong), state, lcp / BitVector.BitsPerByte); remainingWord = ((remainingWord) >> shift) << shift; ulong intermediate = Hashing.CombineInline(remainingWord, ((ulong)remaining) << 32 | (ulong)hash); hash = (uint)intermediate ^ (uint)(intermediate >> 32); return(hash); } } }