/// <summary> /// Consturcts a new Key /// </summary> /// <param name="chars">Chars in the word</param> /// <param name="charMap">Charmap mapping the chars to indices</param> public Key(Queue<char> chars, CharMap charMap) { _charmap = charMap; foreach (char c in chars) { char dequeued = chars.Dequeue(); _amountOccurances[charMap.GetLocation(c)]++; chars.Enqueue(dequeued); } // Use polynomial hashing to compute the hash code. foreach (char c in chars) { unchecked { _hashCode *= 35; _hashCode += _amountOccurances[charMap.GetLocation(c)]; } } }