Example #1
0
        /// <summary>
        /// Check whether the <seealso cref="FacetLabel"/> is equal to the one serialized in
        /// <seealso cref="CharBlockArray"/>.
        /// </summary>
        public static bool EqualsToSerialized(FacetLabel cp, CharBlockArray charBlockArray, int offset)
        {
            int n = charBlockArray.CharAt(offset++);

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

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

                if (!cp.Components[i].Equals(charBlockArray.SubSequence(offset, offset + len)))
                {
                    return(false);
                }
                offset += len;
            }
            return(true);
        }
Example #2
0
        /// <summary>
        /// Check whether the <seealso cref="FacetLabel"/> is equal to the one serialized in
        /// <seealso cref="CharBlockArray"/>.
        /// </summary>
        public static bool EqualsToSerialized(FacetLabel cp, CharBlockArray charBlockArray, int offset)
        {
            int n = charBlockArray.CharAt(offset++);
            if (cp.Length != n)
            {
                return false;
            }
            if (cp.Length == 0)
            {
                return true;
            }

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

                if (string.Equals(cp.Components[i],(charBlockArray.SubSequence(offset, offset + len)).ToString()) == false)
                {
                    return false;
                }
                offset += len;
            }
            return true;
        }
Example #3
0
        /// <summary>
        /// Calculates a hash function of a path that was serialized with
        /// <seealso cref="#serialize(FacetLabel, CharBlockArray)"/>.
        /// </summary>
        public static int HashCodeOfSerialized(CharBlockArray charBlockArray, int offset)
        {
            int length = charBlockArray.CharAt(offset++);
            if (length == 0)
            {
                return 0;
            }

            int hash = length;
            for (int i = 0; i < length; i++)
            {
                int len = charBlockArray.CharAt(offset++);
                hash = hash * 31 + charBlockArray.SubSequence(offset, offset + len).GetHashCode();
                offset += len;
            }
            return hash;
        }
Example #4
0
        /// <summary>
        /// Calculates a hash function of a path that was serialized with
        /// <seealso cref="#serialize(FacetLabel, CharBlockArray)"/>.
        /// </summary>
        public static int HashCodeOfSerialized(CharBlockArray charBlockArray, int offset)
        {
            int length = charBlockArray.CharAt(offset++);

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

            int hash = length;

            for (int i = 0; i < length; i++)
            {
                int len = charBlockArray.CharAt(offset++);
                hash    = hash * 31 + charBlockArray.SubSequence(offset, offset + len).GetHashCode();
                offset += len;
            }
            return(hash);
        }