コード例 #1
0
 private static Dictionary<ulong, string> ReadDictionary(string dictionaryFilePath)
 {
     Dictionary<ulong, string> nameDictionary = new Dictionary<ulong, string>();
     var murmur = new MurmurHash2();
     foreach (string fileName in File.ReadAllLines(dictionaryFilePath))
     {
         ulong hash = BitConverter.ToUInt64(murmur.ComputeHash(Encoding.ASCII.GetBytes(fileName)), 0);
         nameDictionary[hash] = fileName;
     }
     return nameDictionary;
 }
コード例 #2
0
        private static Dictionary<ulong, string> ReadDictionary(string dictionaryFilePath)
        {
            Dictionary<ulong, string> nameDictionary = new Dictionary<ulong, string>();
            var murmur = new MurmurHash2();
            foreach (string fileName in File.ReadAllLines(dictionaryFilePath))
            {
                ulong hash = BitConverter.ToUInt64(murmur.ComputeHash(Encoding.ASCII.GetBytes(fileName)), 0);
                string existingFileName;
                if (nameDictionary.TryGetValue(hash, out existingFileName))
                {
                    Debug.WriteLine("Overwriting '" + hash.ToString("x") +"' '" + existingFileName + "' with '" + fileName + "'");
                }

                nameDictionary[hash] = fileName;
            }
            return nameDictionary;
        }