Exemple #1
0
 int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)
 {
     return(HashCodes.Combine(
                HashCodes.Compute(this.Head, comparer),
                HashCodes.Compute(this.Tail, comparer)
                ));
 }
Exemple #2
0
 public int GetHashCode(STuple <T1, T2> obj)
 {
     return(HashCodes.Combine(
                Comparer1.GetHashCode(obj.Item1),
                Comparer2.GetHashCode(obj.Item2)
                ));
 }
 int IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)
 {
     return(HashCodes.Combine(
                m_prefix.GetHashCode(),
                comparer.GetHashCode(m_items)
                ));
 }
Exemple #4
0
 public ModuleRedirectAllContext(int concurrentLevel, string methodFullName)
 {
     for (int hash = 0; hash < concurrentLevel; ++hash)
     {
         HashCodes.Add(hash);
     }
     MethodFullName = methodFullName;
 }
 public int GetHashCode(STuple <T1, T2, T3, T4> obj)
 {
     return(HashCodes.Combine(
                Comparer1.GetHashCode(obj.Item1),
                Comparer2.GetHashCode(obj.Item2),
                Comparer3.GetHashCode(obj.Item3),
                Comparer4.GetHashCode(obj.Item4)
                ));
 }
Exemple #6
0
        int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)
        {
            int h = this.Head.GetHashCode(comparer);

            // we can't combine with the hashcode of the tail because Combine(H(head), H(tail)) != Combine(H(this[0]), H(this[1]), ... H(this[N-1]))
            foreach (var item in this.Tail)
            {
                h = HashCodes.Combine(h, comparer.GetHashCode(item));
            }
            return(h);
        }
Exemple #7
0
 public override int GetHashCode()
 {
     return(HashCodes.Combine(
                HashCodes.CombineList(this.AdNames),
                HashCodes.CombineList(this.AdKeywords),
                HashCodes.CombineList(this.SongNames),
                this.OutputFormat.GetHashCode(),
                this.OutputFolder.GetHashCode(),
                this.TempFolder.GetHashCode(),
                this.SongRefreshInterval.GetHashCode()
                ));
 }
Exemple #8
0
            public int GetHashCode(STuple <T1, T2, T3, T4, T5> obj)
            {
                int h = HashCodes.Combine(
                    Comparer1.GetHashCode(obj.Item1),
                    Comparer2.GetHashCode(obj.Item2),
                    Comparer3.GetHashCode(obj.Item3)
                    );

                h = HashCodes.Combine(h, Comparer4.GetHashCode(obj.Item4));
                h = HashCodes.Combine(h, Comparer5.GetHashCode(obj.Item5));
                return(h);
            }
Exemple #9
0
        public static int StructuralGetHashCode(IVarTuple?tuple, IEqualityComparer comparer)
        {
            Contract.Requires(comparer != null);

            if (tuple == null)
            {
                return(comparer.GetHashCode(null));
            }

            int h = 0;

            foreach (var item in tuple)
            {
                h = HashCodes.Combine(h, comparer.GetHashCode(item));
            }
            return(h);
        }
        public static int StructuralGetHashCode(IVarTuple tuple, [NotNull] IEqualityComparer comparer)
        {
            Contract.Requires(comparer != null);

            if (object.ReferenceEquals(tuple, null))
            {
                return(comparer.GetHashCode(null));
            }

            int h = 0;

            foreach (var item in tuple)
            {
                h = HashCodes.Combine(h, comparer.GetHashCode(item));
            }
            return(h);
        }
        /// <summary>
        /// Dispatches the expression to one of the more specialized visit methods in this class
        /// </summary>
        /// <param name="node">The expression to visit</param>
        /// <returns><paramref name="node"/></returns>
        public override Expression Visit(Expression node)
        {
            var atRoot = hashElements == null;

            if (atRoot)
            {
                hashElements = new List <object>();
            }
            AddHashElements(node?.NodeType, node?.Type);
            var result = base.Visit(node);

            if (atRoot)
            {
                LastVisitedHashCode = HashCodes.CombineElements(hashElements);
                hashElements        = null;
            }
            return(result);
        }
Exemple #12
0
        int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
        {
            bool canUseCache = object.ReferenceEquals(comparer, SimilarValueComparer.Default);

            if (m_hashCode.HasValue && canUseCache)
            {
                return(m_hashCode.Value);
            }

            int h = 0;

            for (int i = 0; i < m_count; i++)
            {
                h = HashCodes.Combine(h, comparer.GetHashCode(m_slices[i + m_offset]));
            }
            if (canUseCache)
            {
                m_hashCode = h;
            }
            return(h);
        }
Exemple #13
0
 /// <summary>
 /// 调用这个方法处理hash分组结果,真正的处理代码在action中实现。
 /// 1) 在锁内执行;
 /// 2) 需要时初始化UserState并传给action;
 /// 3) 处理完成时删除Context
 /// </summary>
 public int ProcessHash <T>(int hash, Func <T> factory, Func <T, int> action)
 {
     lock (this)
     {
         try
         {
             if (null == UserState)
             {
                 UserState = factory();
             }
             return(action((T)UserState));
         }
         finally
         {
             HashCodes.Remove(hash); // 如果不允许一个hash分组处理措辞,把这个移到开头并判断结果。
             if (HashCodes.Count == 0)
             {
                 Game.App.Instance.Server.TryRemoveManualContext <ManualContext>(SessionId);
             }
         }
     }
 }
Exemple #14
0
        int IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)
        {
            // the cached hashcode is only valid for the default comparer!
            bool canUseCache = object.ReferenceEquals(comparer, SimilarValueComparer.Default);

            if (m_hashCode.HasValue && canUseCache)
            {
                return(m_hashCode.Value);
            }

            int h = 0;

            for (int i = 0; i < m_count; i++)
            {
                var item = m_items[i + m_offset];

                h = HashCodes.Combine(h, comparer.GetHashCode(item));
            }
            if (canUseCache)
            {
                m_hashCode = h;
            }
            return(h);
        }
 public override int GetHashCode()
 => HashCodes.Combine(this.Name?.GetHashCode() ?? -1, (this.LayerId ?? string.Empty).GetHashCode());
 public override int GetHashCode()
 {
     return(HashCodes.Combine(this.Left.GetHashCode(), this.Right.GetHashCode()));
 }
Exemple #17
0
 public override int GetHashCode()
 {
     return(HashCodes.Combine(this.Type, this.Value.GetHashCode()));
 }
 public int GetHashCode(IVarTuple obj)
 {
     return(HashCodes.Compute(obj, m_comparer));
 }
 public override int GetHashCode()
 {
     return(HashCodes.Combine(this.Path.GetHashCode(), this.Layer.GetHashCode()));
 }