Ejemplo n.º 1
0
        /// <summary>
        ///     Serves as a hash function for a particular type. <see cref="M:System.Object.GetHashCode"></see> is suitable for use
        ///     in hashing algorithms and data structures like a hash table.
        /// </summary>
        /// <returns>
        ///     A hash code for the current <see cref="T:System.Object"></see>.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override int GetHashCode()
        {
            // Getting hash codes from volatile variables doesn't seem a good move... //TODO Find an immutable way?
            var result = Name?.GetHashCode() ?? 0;

            result = (result * 397) ^ (KeyNameValues?.GetHashCode() ?? 0);
            result = (result * 397) ^ (KeyChilds?.GetHashCode() ?? 0);
            result = (result * 397) ^ (FirstParent?.GetHashCode() ?? 0);
            result = (result * 397) ^ (Parent?.GetHashCode() ?? 0);
            result = (result * 397) ^ NextSubKeyIndex.GetHashCode();
            result = (result * 397) ^ NextKeyValueIndex.GetHashCode();
            result = (result * 397) ^ DistanceFromTop.GetHashCode();
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Serves as a hash function for a particular type. <see cref="M:System.Object.GetHashCode"></see> is suitable for use in hashing algorithms and data structures like a hash table.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"></see>.
 /// </returns>
 /// <filterpriority>2</filterpriority>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (Name != null ? Name.GetHashCode() : 0);
         result = (result * 397) ^ (KeyNameValues != null ? KeyNameValues.GetHashCode() : 0);
         result = (result * 397) ^ (KeyChilds != null ? KeyChilds.GetHashCode() : 0);
         result = (result * 397) ^ (FirstParent != null ? FirstParent.GetHashCode() : 0);
         result = (result * 397) ^ (Parent != null ? Parent.GetHashCode() : 0);
         result = (result * 397) ^ NextSubKeyIndex.GetHashCode();
         result = (result * 397) ^ NextKeyValueIndex.GetHashCode();
         result = (result * 397) ^ DistanceFromTop.GetHashCode();
         return(result);
     }
 }