Пример #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);
        }
Пример #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;
        }
Пример #3
0
 /// <summary>
 /// Serializes the given <seealso cref="FacetLabel"/> to the <seealso cref="CharBlockArray"/>. </summary>
 public static void Serialize(FacetLabel cp, CharBlockArray charBlockArray)
 {
     charBlockArray.Append((char)cp.Length);
     if (cp.Length == 0)
     {
         return;
     }
     for (int i = 0; i < cp.Length; i++)
     {
         charBlockArray.Append((char)cp.Components[i].Length);
         charBlockArray.Append(cp.Components[i]);
     }
 }
Пример #4
0
 /// <summary>
 /// Serializes the given <seealso cref="FacetLabel"/> to the <seealso cref="CharBlockArray"/>. </summary>
 public static void Serialize(FacetLabel cp, CharBlockArray charBlockArray)
 {
     charBlockArray.Append((char)cp.Length);
     if (cp.Length == 0)
     {
         return;
     }
     for (int i = 0; i < cp.Length; i++)
     {
         charBlockArray.Append((char)cp.Components[i].Length);
         charBlockArray.Append(cp.Components[i]);
     }
 }
Пример #5
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;
        }
Пример #6
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);
        }