Exemple #1
0
        /// <summary>
        /// Compares the cost of this path with another one.
        /// </summary>
        /// <param name="other">Other <see cref="SegmentedPath{T}"/> to compare.</param>
        /// <returns>
        /// <para>Less than zero: This path has the cost less than other path.</para>
        /// <para>Zero: This path has the cost equal to other node.</para>
        /// <para>Greater than zero: This path has the cost greater than other node.</para>
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="other"/> is <see langword="null"/>.</exception>
        public int CompareTo(SegmentedPath <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            int scoreCompare = this.Cost.CompareTo(other.Cost);

            return(scoreCompare);
        }
Exemple #2
0
        /// <summary>
        /// Returns a value indicating whether this istance and a specific <see cref="SegmentedPath{T}"/> rappresent the same path.
        /// </summary>
        /// <param name="other">Other <see cref="SegmentedPath{T}"/> istance.</param>
        /// <returns>True if this and the other istance rappresent the same path.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="other"/> is <see langword="null"/>.</exception>
        public bool Equals(SegmentedPath <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            if (this.CompareTo(other) == 0)
            {
                for (int i = 0; i < this.Segments.Count; i++)
                {
                    if (!this.Segments[i].Equals(other.Segments[i]))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }