/// <summary> /// Compare these coordinates to the specified coordinates. /// </summary> /// <param name="other">coordinates to compare</param> /// <returns>comparison result</returns> /// <exception cref="ArgumentNullException">null coords</exception> public int CompareTo(ITextPoint other) { if (ReferenceEquals(this, other)) { return(0); } if (other is null) { return(1); } if (!(other is TokenTextPoint o)) { throw new ArgumentNullException(nameof(other)); } if (Y != o.Y) { return(Y - o.Y); } if (X != o.X) { return(X - o.X); } if (At != o.At) { return(At - o.At); } return(Run - o.Run); }
/// <summary> /// Copy location values from the specified source point into this point. /// </summary> /// <param name="point">source point</param> /// <exception cref="ArgumentNullException">null source point</exception> public void CopyFrom(ITextPoint point) { if (!(point is TokenTextPoint p)) { throw new ArgumentNullException(nameof(point)); } Y = p.Y; X = p.X; At = p.At; Run = p.Run; }
/// <summary> /// Compare this point to the specified one without taking into account /// token portions (i.e. <see cref="At"/> and <see cref="Run"/>). /// </summary> /// <param name="other">the point to compare to this point</param> /// <returns>comparison result</returns> /// <exception cref="ArgumentNullException">null point</exception> public int IntegralCompareTo(ITextPoint other) { if (!(other is TokenTextPoint o)) { throw new ArgumentNullException(nameof(other)); } if (Y != o.Y) { return(Y - o.Y); } if (X != o.X) { return(X - o.X); } return(0); }
/// <summary> /// True if these coordinates are equal to the specified coordinates. /// </summary> /// <param name="other"></param> /// <returns>True if equal.</returns> public bool Equals(ITextPoint other) { return(CompareTo(other) == 0); }