Пример #1
0
        public static void WriteFileWithCheckSum <T>(T hashType, string path) where T : HashAlgorithm

        {
            if (!File.Exists(path))
            {
                File.Create(path);
            }


            HashCounter.GetHash hashFunction;
            HashCounter.InitHashFunction <T>(hashType, out hashFunction);

            try
            {
                StringBuilder[] sBuilder = new StringBuilder[files.Count];
                string[]        buff     = new string[files.Count];
                for (int i = 0; i < files.Count; i++)
                {
                    sBuilder[i] = new StringBuilder();
                    sBuilder[i].Append(files[i] + "|" + hashFunction(File.ReadAllText(@files[i])));
                }

                using (StreamWriter sw = new StreamWriter(path, false))
                {
                    for (int i = 0; i < sBuilder.Length; i++)
                    {
                        sw.WriteLine(sBuilder[i].ToString());
                    }
                }
            }
            catch (Exception e) { Console.WriteLine(e.Message + "\n" + e.StackTrace); }
        }
Пример #2
0
        public void ValidComparer_Null()
        {
            // Check both with and without a given capacity
            var hashCounter = new HashCounter <TKey>(null);

            Assert.AreEqual(EqualityComparer <TKey> .Default, hashCounter.Comparer);

            hashCounter = new HashCounter <TKey>(1, null);
            Assert.AreEqual(EqualityComparer <TKey> .Default, hashCounter.Comparer);
        }
Пример #3
0
        private static void Main()
        {
            var hashCounter = new HashCounter <Char>();

            hashCounter.Update("1234512345");
            foreach (DictionaryEntry k in hashCounter.State())
            {
                Console.WriteLine(k.Key + " " + k.Value);
            }
            ;
        }
Пример #4
0
        BinaryHeap <EdgeCost> InitCosts()
        {
            var costs = new BinaryHeap <EdgeCost>(new EdgeCost.Comparer());
            var edges = new HashCounter <Edge>();

            foreach (var f in faceDb.Faces)
            {
                for (var iv = 0; iv < 3; iv++)
                {
                    var edge = new Edge(f[iv], f[iv + 1]);
                    edges[edge]++;
                }
            }
            foreach (var edge in edges)
            {
                var cost = CalculateCost(edge);
                costs.Add(cost);
            }
            return(costs);
        }
Пример #5
0
 public void Setup()
 {
     _hashCounter = new HashCounter <string>();
 }