当前位置: 首页>>代码示例>>C#>>正文


C# IPersistentVector.GetHashCode方法代码示例

本文整理汇总了C#中IPersistentVector.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# IPersistentVector.GetHashCode方法的具体用法?C# IPersistentVector.GetHashCode怎么用?C# IPersistentVector.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPersistentVector的用法示例。


在下文中一共展示了IPersistentVector.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: doEquals

        /// <summary>
        /// Compares an <see cref="IPersistentVector">IPersistentVector</see> to another object for equality.
        /// </summary>
        /// <param name="v">The <see cref="IPersistentVector">IPersistentVector</see> to compare.</param>
        /// <param name="obj">The other object to compare.</param>
        /// <returns><value>true</value> if the specified Object is equal to the current Object; 
        /// otherwise, <value>false</value>.
        /// </returns>
        public static bool doEquals(IPersistentVector v, object obj)
        {
            if (obj is IList || obj is IPersistentVector)
            {
                IList ma = obj as IList;

                if (ma.Count != v.count() || ma.GetHashCode() != v.GetHashCode())
                    return false;

                for (int i = 0; i < v.count(); i++)
                {
                    if (!Util.equals(v.nth(i), ma[i]))
                        return false;
                }
                return true;
            }
            else
            {
                if (!(obj is Sequential))
                    return false;

                ISeq ms = RT.seq(obj);

                for (int i = 0; i < v.count(); i++, ms = ms.next())
                {
                    if (ms == null || !Util.equals(v.nth(i), ms.first()))
                        return false;
                }
                if (ms != null)
                    return false;
            }
            return true;
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:41,代码来源:APersistentVector.cs

示例2: doEquals

        /// <summary>
        /// Compares an <see cref="IPersistentVector">IPersistentVector</see> to another object for equality.
        /// </summary>
        /// <param name="v">The <see cref="IPersistentVector">IPersistentVector</see> to compare.</param>
        /// <param name="obj">The other object to compare.</param>
        /// <returns><value>true</value> if the specified Object is equal to the current Object; 
        /// otherwise, <value>false</value>.
        /// </returns>
        public static bool doEquals(IPersistentVector v, object obj)
        {
            if ( obj is IList || obj is IPersistentVector )
            {
                IList ma = obj as IList;

                if (ma.Count != v.count() || ma.GetHashCode() != v.GetHashCode())
                    return false;

                for ( int i=0; i<v.count(); i++ )
                {
                    if (!Util.equals(v.nth(i), ma[i]))
                        return false;
                }
                return true;
            }

            // Example in original code of Sequential/IPersistentVector conflation.

            //if(!(obj instanceof Sequential))
            //        return false;
            //    ISeq ms = ((IPersistentCollection) obj).seq();
            //    for(int i = 0; i < v.count(); i++, ms = ms.rest())
            //        {
            //        if(ms == null || !Util.equals(v.nth(i), ms.first()))
            //            return false;
            //        }
            //    if(ms != null)
            //        return false;
            //    }

            //return true;

            ISeq ms = obj as ISeq;
            if (ms == null)
            {
                IPersistentCollection mc = obj as IPersistentCollection;
                if (mc == null)
                    return false;
                ms = mc.seq();
            }

            // Once we have the ISeq, we're ready to go.

            for (int i = 0; i < v.count(); i++, ms = ms.rest())
            {
                if (ms == null || !Util.equals(v.nth(i), ms.first()))
                    return false;
            }
            if (ms != null)
                return false;

            return true;
        }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:62,代码来源:APersistentVector.cs


注:本文中的IPersistentVector.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。