Esempio n. 1
0
        /// <summary>
        ///     Compare the position to another position.
        /// </summary>
        /// <param name="other">
        ///     The other position.
        /// </param>
        /// <returns>
        ///     0 if the positions are equal, greater than 0 if the other position is less than the current position, less than 0 if the other position is greater than the current position.
        /// </returns>
        public int CompareTo(Position other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            if (IsOneBased)
            {
                other = other.ToOneBased();
            }
            else if (IsZeroBased)
            {
                other = other.ToZeroBased();
            }

            int lineComparison = LineNumber.CompareTo(other.LineNumber);

            if (lineComparison != 0)
            {
                return(lineComparison);
            }

            return(ColumnNumber.CompareTo(other.ColumnNumber));
        }
Esempio n. 2
0
        /// <summary>
        /// Implemented CompareTo method
        /// </summary>
        /// <param name="other">Object to compare</param>
        /// <returns>0 if values are the same, -1 if this object is smaller, 1 if it is bigger</returns>
        public int CompareTo(Cell other)
        {
            if (RowNumber == other.RowNumber)
            {
                return(ColumnNumber.CompareTo(other.ColumnNumber));
            }

            return(RowNumber.CompareTo(other.RowNumber));
        }
Esempio n. 3
0
        /// <summary>
        ///     Compare the position to another position.
        /// </summary>
        /// <param name="other">
        ///     The other position.
        /// </param>
        /// <returns>
        ///     0 if the positions are equal, greater than 0 if the other position is less than the current position, less than 0 if the other position is greater than the current position.
        /// </returns>
        public int CompareTo(Position other)
        {
            if (IsOneBased)
            {
                other = other.ToOneBased();
            }
            else if (IsZeroBased)
            {
                other = other.ToZeroBased();
            }

            int lineComparison = LineNumber.CompareTo(other.LineNumber);

            if (lineComparison != 0)
            {
                return(lineComparison);
            }

            return(ColumnNumber.CompareTo(other.ColumnNumber));
        }