GitList
Repositories
Help
Report an Issue
boggleNet
Code
Commits
Branches
Tags
Search
Tree:
645335e
Branches
Tags
master
boggleNet
WordComparer.cs
Revert "Removing byte order mark in file using for f in `ls`; do awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' $f > $f; done"
Dev Ghai
commited
645335e
at 2013-09-23 06:37:32
WordComparer.cs
Blame
History
Raw
using System.Collections.Generic; namespace Boggle { /// <summary> /// Equality comparer used for HashSet. No longer used as I switched to Dictionaries. /// </summary> public class WordComparer : EqualityComparer<WordOnBoard> { public override bool Equals(WordOnBoard x, WordOnBoard y) { return string.Compare(x.Word, y.Word, true) == 0; } public override int GetHashCode(WordOnBoard obj) { int hash = 0; for (int i = 0; i < obj.Word.Length; i++) { hash += (int)obj.Word[i] * 10 ^ (obj.Word.Length - 1 - i); //cat would result in 99 * 10^2 + 97 * 10^1 + 116 * 10^0 = 10986 } return hash; } } }