Exemple #1
0
        public override int GetHashCode()
        {
            int result = 7;

            IntHash.Combine(ref result, produce);
            IntHash.Combine(ref result, express.GetHashCode());
            IntHash.Combine(ref result, index);

            return(result);
        }
Exemple #2
0
        public override int GetHashCode()
        {
            int result = 7;

            IntHash.Combine(ref result, (int)blockType);
            if (catchType != null)
            {
                IntHash.Combine(ref result, catchType.GetHashCode());
            }

            return(result);
        }
        public unsafe override int GetHashCode()
        {
            int result = low.GetHashCode();

            fixed(ulong *ptr = &mid)
            for (int x = Size64 - 2; --x >= 0;)
            {
                result = IntHash.Combine(result, ptr[x].GetHashCode());
            }

            return(IntHash.Combine(result, flag.GetHashCode()));
        }
        public override int GetHashCode()
        {
            int sidx     = this.sidx;
            int hashcode = str.GetFixedHashcode(sidx, eidx - sidx);

            for (FMultiRngString n = next; n != null; n = n.next)
            {
                sidx     = n.sidx;
                hashcode = IntHash.CombineMOD(hashcode, str.GetFixedHashcode(sidx, n.eidx - sidx));
            }

            return(hashcode);
        }
        public static int HashCode <T>(this IEnumerable <T> arr)
        {
            if (arr == null)
            {
                return(0);
            }

            int result = 7;

            foreach (T v in arr)
            {
                result = IntHash.CombineMOD(result, v?.GetHashCode() ?? 0);
            }

            return(result);
        }
        public static int HashCodeFast <T>(this IEnumerable <T> arr) where T : struct
        {
            if (arr == null)
            {
                return(0);
            }

            int result = 7;

            foreach (T v in arr)
            {
                result = IntHash.CombineMOD(result, v.GetHashCode());
            }

            return(result);
        }
        public static int HashCodeFast <T>(this T[] arr) where T : struct
        {
            if (arr == null)
            {
                return(0);
            }

            int x      = arr.Length;
            int result = 7;

            while (--x >= 0)
            {
                result = IntHash.CombineMOD(result, arr[x].GetHashCode());
            }

            return(result);
        }
        public static int HashCode <T>(this T[] arr)
        {
            if (arr == null)
            {
                return(0);
            }

            int x      = arr.Length;
            int result = 7;

            while (--x >= 0)
            {
                result = IntHash.CombineMOD(result, arr[x]?.GetHashCode() ?? 0);
            }

            return(result);
        }
Exemple #9
0
        static void RenameFileToHashname(string filename, IntHash hash, Dictionary <string, IntHash> filenamesToFileHash)
        {
            string hashname = GetHashname(filename, hash);

            if (!string.Equals(filename, hashname, StringComparison.CurrentCultureIgnoreCase))
            {
                if (File.Exists(hashname))
                {
                    RenameFileToHashname(hashname, filenamesToFileHash[hashname], filenamesToFileHash);
                }
                File.Move(filename, hashname);
                NonBlockingConsole.Title = String.Format("Renamed {0} to {1}", filename, hashname);
            }
            else
            {
                NonBlockingConsole.Title = String.Format("{0} left alone; already has a hashname", filename);
            }
        }
Exemple #10
0
        private static void HashAndDedupeFile(ref Dictionary <IntHash, string> hashToOriginalFilenames, string filename)
        {
            var file    = File.OpenRead(filename);
            var md5Hash = new IntHash(MD5.Create().ComputeHash(file));

            file.Close();
            if (!hashToOriginalFilenames.ContainsKey(md5Hash))
            {
                hashToOriginalFilenames[md5Hash] = filename;
            }
            else                //collision!
            {
                NonBlockingConsole.WriteLine(String.Format("Dupe detected! {0} hashed as a duplicate of {1} with an MD5 of {2}. Deleting duplicate...", filename, hashToOriginalFilenames[md5Hash], md5Hash));
                FileSystem.DeleteFile(
                    filename,
                    UIOption.OnlyErrorDialogs,
                    RecycleOption.SendToRecycleBin,
                    UICancelOption.ThrowException
                    );
            }
        }
Exemple #11
0
 static string GetHashname(string originalFilename, IntHash hash)
 {
     return(Path.GetDirectoryName(originalFilename) + Path.DirectorySeparatorChar + hash.ToString() + Path.GetExtension(originalFilename));
 }
Exemple #12
0
        public override int GetHashCode()
        {
            int result = low.GetHashCode();

            return(IntHash.Combine(result, high.GetHashCode()));
        }