/// <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, offset + len), StringComparison.Ordinal)) { return(false); } offset += len; } return(true); }
/// <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.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; }
/// <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, offset + len).GetHashCode(); offset += len; } return(hash); }
/// <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.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), StringComparison.Ordinal)) { return false; } offset += len; } return true; }