コード例 #1
0
        /// <summary>
        /// Check whether the <see cref="FacetLabel"/> is equal to the one serialized in
        /// <see cref="CharBlockArray"/>.
        /// </summary>
        public static bool EqualsToSerialized(FacetLabel cp, CharBlockArray charBlockArray, int offset)
        {
            int n = charBlockArray[offset++];

            if (cp.Length != n)
            {
                return(false);
            }
            if (cp.Length == 0)
            {
                return(true);
            }

            for (int i = 0; i < cp.Length; i++)
            {
                int len = charBlockArray[offset++];
                if (len != cp.Components[i].Length)
                {
                    return(false);
                }

                if (!cp.Components[i].Equals(charBlockArray.Subsequence(offset, len).ToString(), StringComparison.Ordinal)) // LUCENENET: Corrected 2nd Subsequence parameter
                {
                    return(false);
                }
                offset += len;
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Calculates a hash function of a path that was serialized with
        /// <see cref="Serialize(FacetLabel, CharBlockArray)"/>.
        /// </summary>
        public static int HashCodeOfSerialized(CharBlockArray charBlockArray, int offset)
        {
            int length = charBlockArray[offset++];

            if (length == 0)
            {
                return(0);
            }

            int hash = length;

            for (int i = 0; i < length; i++)
            {
                int len = charBlockArray[offset++];
                hash    = hash * 31 + charBlockArray.Subsequence(offset, len).GetHashCode(); // LUCENENET: Corrected 2nd Subsequence parameter
                offset += len;
            }
            return(hash);
        }