Example #1
0
        /// <summary>
        /// Compares two sequence ranges.
        /// </summary>
        /// <param name="other">SequenceRange instance to compare.</param>
        /// <returns>
        /// If the Start values of the two ranges are identical then the
        /// result of this comparison is the result from calling CompareTo() on
        /// the two End values. If the Start values are not equal then the result
        /// of this comparison is the result of calling CompareTo() on the two
        /// Start values.
        /// </returns>
        public int CompareTo(ISequenceRange other)
        {
            int compare = Start.CompareTo(other.Start);

            if (compare == 0)
            {
                compare = End.CompareTo(other.End);
            }

            if (compare == 0)
            {
                compare = string.Compare(ID, other.ID, StringComparison.OrdinalIgnoreCase);
            }

            if (compare == 0)
            {
                compare = ParentSeqRanges.Count.CompareTo(other.ParentSeqRanges.Count);

                if (compare == 0)
                {
                    for (int index = 0; index < ParentSeqRanges.Count; index++)
                    {
                        compare = ParentSeqRanges[index].CompareTo(other.ParentSeqRanges[index]);
                        if (compare != 0)
                        {
                            break;
                        }
                    }
                }
            }

            return(compare);
        }
Example #2
0
        /// <summary>
        ///  Compares this instance to a specified object and returns an
        ///  indication of their relative values.
        /// </summary>
        /// <param name="obj">Loction instance to compare.</param>
        /// <returns>
        /// A signed number indicating the relative values of this instance and value.
        /// Return Value Description Less than zero This instance is less than value.
        /// Zero This instance is equal to value. Greater than zero This instance is
        /// greater than value.  -or- value is null.
        /// </returns>
        public int CompareTo(object obj)
        {
            ILocation other = obj as ILocation;

            if (other == null)
            {
                return(1);
            }

            int startresult = Start.CompareTo(other.Start);

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

            int endresult = End.CompareTo(other.End);

            if (startresult == endresult)
            {
                return(0);
            }

            return(endresult);
        }
        /// <summary>
        /// This comparer is designed to prefer (i.e. evaluate as smaller) more narrow subset ranges,
        /// where there is no overlap or a partial intersection, the one with the higher start is
        /// preferred.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other" /> parameter.Zero This object is equal to <paramref name="other" />. Greater than zero This object is greater than <paramref name="other" />.</returns>
        public int CompareTo(PostalCodeRange other)
        {
            // prefer (evaluate as smaller) the higher start
            if (other == null)
            {
                return(1);
            }

            if (Start == null && other.Start != null)
            {
                // Default range (Start=End=Null) must be before any other
                return(-1);
            }

            if (Start != null)
            {
                // prefer (evaluate as smaller) the lower start
                var comparison = Start.CompareTo(other.Start);
                if (comparison != 0)
                {
                    return(comparison);
                }
            }

            if (End == null && other.End != null)
            {
                return(-1);
            }

            // prefer (evaluate as smaller) the lower end
            return(End != null?End.CompareTo(other.End) : 0);
        }
Example #4
0
        /// <summary>
        /// Determines whether [is in range] [the specified t].
        /// </summary>
        /// <param name="t">The t.</param>
        /// <returns>
        ///     <c>true</c> if [is in range] [the specified t]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsInRange(T t)
        {
            int startComparationResult = Start.CompareTo(t);

            int endComparationResult = End.CompareTo(t);

            return((startComparationResult == -1 || startComparationResult == 0) && (endComparationResult == 1 || endComparationResult == 0) ? true : false);
        }
Example #5
0
        public int CompareTo(DateRange other)
        {
            var result = Start.CompareTo(other.Start);

            if (result == 0)
            {
                result = End.CompareTo(other.End);
            }
            return(result);
        }
Example #6
0
        public int CompareTo(DateTimeSize other)
        {
            int compare = Start.CompareTo(other.Start);

            if (compare == 0) //Same starttime, use endtime
            {
                compare = End.CompareTo(other.End);
            }
            return(compare);
        }
Example #7
0
        public int CompareTo(SimpleInterval other)
        {
            if (Start != other.Start)
            {
                return(Start.CompareTo(other.Start));
            }
            if (End != other.End)
            {
                return(End.CompareTo(other.End));
            }

            return(0);
        }
Example #8
0
        public Int32 CompareTo(T other)
        {
            if (End.CompareTo(other) < 0)
            {
                return(-1);
            }

            if (Begin.CompareTo(other) > 0)
            {
                return(+1);
            }

            return(0);
        }
        /// <summary>
        /// Tests if interval contains given value
        /// </summary>
        /// <param name="val">value to check</param>
        /// <returns>True when value is contained in the interval</returns>
        public bool Contains(T val)
        {
            if (Start.GetType() != typeof(T) || End.GetType() != typeof(T))
            {
                throw new ArgumentException("Type mismatch", "val");
            }

            var lower = LowerBoundIntervalType == IntervalType.Open
                ? Start.CompareTo(val) < 0
                : Start.CompareTo(val) <= 0;
            var upper = UpperBoundIntervalType == IntervalType.Open
                ? End.CompareTo(val) > 0
                : End.CompareTo(val) >= 0;

            return(lower && upper);
        }
        /// <summary>
        /// Check if the intervals overlap at any point
        /// </summary>
        /// <param name="interval">interval to check overlap</param>
        /// <returns>True when intervals overlap</returns>
        public bool Overlaps(Interval <T> interval)
        {
            if (Start.GetType() != typeof(T) || End.GetType() != typeof(T))
            {
                throw new ArgumentException("Type mismatch", "interval");
            }

            var lower = LowerBoundIntervalType == IntervalType.Open
                ? Start.CompareTo(interval.End) < 0
                : Start.CompareTo(interval.End) <= 0;
            var upper = UpperBoundIntervalType == IntervalType.Open
                ? End.CompareTo(interval.Start) > 0
                : End.CompareTo(interval.Start) >= 0;

            return(lower && upper);
        }
Example #11
0
        int IComparable <ILine> .CompareTo(ILine other)
        {
            int start = Start.CompareTo(other.Start);
            int end   = End.CompareTo(other.End);

            if (start < 0 || end < 0)
            {
                return(-1);
            }

            if (start > 0 || end > 0)
            {
                return(1);
            }

            return(0);
        }
Example #12
0
        public int CompareTo(RouteLocations other)
        {
            if (Location != null && other.Location == null)
            {
                return(-1);
            }
            if (Location == null && other.Location != null)
            {
                return(1);
            }
            if (Location != null && other.Location != null)
            {
                return(Location.CompareTo(other.Location));
            }
            var startComparison = Start.CompareTo(other.Start);

            return(startComparison != 0 ? startComparison : End.CompareTo(other.End));
        }
Example #13
0
        public int CompareTo(IPAddressRange other)
        {
            // compare begin addresses first
            int compare = Begin.CompareTo(other.Begin);

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

            // begin address are equal, compare end addresses
            compare = End.CompareTo(other.End);
            if (compare != 0)
            {
                return(compare);
            }

            return(0); // equal
        }
 /// <summary>
 ///		Compara con otra definíción de contenido
 /// </summary>
 public int CompareTo(TokenDefinition objDefinition)
 {
     if (objDefinition == null)
     {
         return(-1);
     }
     else if (Start == objDefinition.Start)
     {
         if (End == null)
         {
             return(-1);
         }
         else
         {
             return(End.CompareTo(objDefinition.End));
         }
     }
     else
     {
         return(Start.CompareTo(objDefinition.Start));
     }
 }
Example #15
0
        public Int32 CompareTo(Range <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            if (End.CompareTo(other.Begin) < 0)
            {
                // does not overlap and less then other
                return(-1);
            }

            if (Begin.CompareTo(other.End) > 0)
            {
                // does not overlap and greater then other
                return(+1);
            }

            // does overlap
            return(0);
        }
Example #16
0
        public bool Contains(T Point)
        {
            int StartComparisonWithPoint = Start.CompareTo(Point);
            int EndComparisonWithPoint   = End.CompareTo(Point);

            if (StartComparisonWithPoint > 0 && EndComparisonWithPoint < 0)
            {
                return(true);
            }

            if (StartComparisonWithPoint == 0 && StartType == IntervalBoundaryType.Closed)
            {
                return(true);
            }

            if (EndComparisonWithPoint == 0 && EndType == IntervalBoundaryType.Closed)
            {
                return(true);
            }

            return(false);
        }
Example #17
0
 /// <summary>
 /// Indicated wether the requested date is on or within start/end bounds.
 /// </summary>
 /// <param name="date">requested date to check</param>
 /// <returns>true if this date is on or within [Start;End], false otherwise.</returns>
 public bool Contains(DateTime date)
 {
     return(Start.CompareTo(date) <= 0 && End.CompareTo(date) >= 0);
 }
 public int CompareTo(ScheduleActivity other)
 {
     return(End.CompareTo(other.End));
 }
        /// <summary>
        /// Compare two intervals
        /// </summary>
        /// <param name="i">interval to compare</param>
        /// <returns></returns>
        public int CompareTo(Interval <T> i)
        {
            if (LowerBoundIntervalType == i.LowerBoundIntervalType && UpperBoundIntervalType == i.UpperBoundIntervalType)
            {
                // Both pairs of lower and upper intervaltypes are the same as their partner ()-(), []-[], (]-(], [)-[)
                //    L         R
                // ○-----○ & ○-----○
                // ○-----• & ○-----•
                // •-----○ & •-----○
                // •-----• & •-----•
                return((Start.CompareTo(i.Start) == -1) ? -1 :
                       (Start.CompareTo(i.Start) == 1) ? 1 :
                       End.CompareTo(i.End));
            }
            else if (LowerBoundIntervalType != i.LowerBoundIntervalType && UpperBoundIntervalType == i.UpperBoundIntervalType)
            {
                // Lower interval types are opposite their partner ()-[), [)-(), (]-[], []-(]
                //    L         R
                // ○-----○ & •-----○
                // ○-----• & •-----•
                // •-----○ & ○-----○
                // •-----• & ○-----•
                return((LowerBoundIntervalType == IntervalType.Open && i.LowerBoundIntervalType == IntervalType.Closed && Start.CompareTo(i.Start) == 0) ? 1 :
                       (LowerBoundIntervalType == IntervalType.Closed && i.LowerBoundIntervalType == IntervalType.Open && Start.CompareTo(i.Start) == 0) ? -1 :
                       (Start.CompareTo(i.Start) == -1) ? -1 :
                       (Start.CompareTo(i.Start) == 1) ? 1 :
                       End.CompareTo(i.End));
            }
            else if (LowerBoundIntervalType == i.LowerBoundIntervalType && UpperBoundIntervalType != i.UpperBoundIntervalType)
            {
                // Upper interval types are opposite their partner ()-(], [)-[], (]-(), []-[)
                //    L         R
                // ○-----○ & ○-----•
                // ○-----• & ○-----○
                // •-----○ & •-----•
                // •-----• & •-----○
                return((Start.CompareTo(i.Start) == -1) ? -1 :
                       (Start.CompareTo(i.Start) == 1) ? 1 :
                       (UpperBoundIntervalType == IntervalType.Open && i.UpperBoundIntervalType == IntervalType.Closed && End.CompareTo(i.End) == 0) ? -1 :
                       (UpperBoundIntervalType == IntervalType.Closed && i.UpperBoundIntervalType == IntervalType.Open && End.CompareTo(i.End) == 0) ? 1 : 0);
            }
            else if (LowerBoundIntervalType != i.LowerBoundIntervalType && UpperBoundIntervalType != i.UpperBoundIntervalType)
            {
                // Both pairs of lower and upper intervaltypes are opposite of their partner ()-[], (]-[), [)-(], []-()
                //    L         R
                // ○-----○ & •-----•
                // ○-----• & •-----○
                // •-----○ & ○-----•
                // •-----• & ○-----○
                return((LowerBoundIntervalType == IntervalType.Open && i.LowerBoundIntervalType == IntervalType.Closed && Start.CompareTo(i.Start) == 0) ? 1 :
                       (LowerBoundIntervalType == IntervalType.Closed && i.LowerBoundIntervalType == IntervalType.Open && Start.CompareTo(i.Start) == 0) ? -1 :
                       (Start.CompareTo(i.Start) == -1) ? -1 :
                       (Start.CompareTo(i.Start) == 1) ? 1 :
                       (UpperBoundIntervalType == IntervalType.Open && i.UpperBoundIntervalType == IntervalType.Closed && End.CompareTo(i.End) == 0) ? -1 :
                       (UpperBoundIntervalType == IntervalType.Closed && i.UpperBoundIntervalType == IntervalType.Open && End.CompareTo(i.End) == 0) ? 1 :
                       End.CompareTo(i.End));
            }

            // Identical interval
            return(0);
        }
Example #20
0
        public int CompareTo(PogoEntry?p)
        {
            if (p == null)
            {
                return(1);
            }

            if (p.Start != null)
            {
                if (Start == null)
                {
                    return(1);
                }
                var date = Start.CompareTo(p.Start);
                if (date != 0)
                {
                    return(date);
                }
            }
            else
            {
                if (Start != null)
                {
                    return(-1);
                }
            }

            if (p.End != null)
            {
                if (End == null)
                {
                    return(1);
                }
                var date = End.CompareTo(p.End);
                if (date != 0)
                {
                    return(date);
                }
            }
            else
            {
                if (End != null)
                {
                    return(-1);
                }
            }

            if (Type != p.Type)
            {
                return(Type.CompareTo(p.Type));
            }

            if (Shiny != p.Shiny)
            {
                return(Shiny.CompareTo(p.Shiny));
            }
            if (Gender != p.Gender)
            {
                return(Gender.CompareTo(p.Gender));
            }

            return(string.Compare(Comment, p.Comment, StringComparison.OrdinalIgnoreCase));
        }
Example #21
0
            public int CompareTo(StartLength other)
            {
                var comp = End.CompareTo(other.End);

                return(comp != 0? comp : Start.CompareTo(other.Start));
            }
Example #22
0
        public bool Contains(TScalar x)
        {
            var startCompare = Start.CompareTo(x);

            return(startCompare == 0 || ((startCompare < 0) && (End.CompareTo(x) > 0)));
        }
Example #23
0
 public bool Contains(IInterval <TScalar> other)
 {
     return((Start.CompareTo(other.Start) <= 0) && (End.CompareTo(other.End) > 0));
 }