コード例 #1
0
        public int CompareTo(object obj)
        {
            if (obj.GetType() != typeof(Transition))
            {
                return(-1);
            }

            Transition other = obj as Transition;

            int c1 = From.CompareTo(other.From);
            int c2 = To.CompareTo(other.To);

            if (c1 == c2 && c2 == 0)
            {
                return(0);
            }

            if (c1 < 0 || c1 > 0)
            {
                return(c1);
            }

            if (c2 < 0 || c2 > 0)
            {
                return(c2);
            }

            return(0);
        }
コード例 #2
0
 public bool Contains(T value)
 {
     if (From.CompareTo(To) <= 0)
     {
         return(From.CompareTo(value) <= 0 && value.CompareTo(To) <= 0);
     }
     return(To.CompareTo(value) <= 0 && value.CompareTo(From) <= 0);
 }
コード例 #3
0
        public int CompareTo(TimeSlot other)
        {
            if (From == other.From)
            {
                return(To.CompareTo(other.To));
            }

            return(From.CompareTo(other.From));
        }
コード例 #4
0
ファイル: CharRange.cs プロジェクト: tpetmanson/latvian
        public int CompareTo(CharRange other)
        {
            int c = From.CompareTo(other.From);

            if (c == 0)
            {
                return(To.CompareTo(other.To));
            }
            return(c);
        }
コード例 #5
0
        /// <summary>
        /// Compares the value of this instance to a specified FuzzyDateRange value and returns an integer
        /// that indicates whether this instance is earlier than, the same as, or later than the
        /// specified FuzzyDateRange value.
        /// </summary>
        /// <param name="value">The object to compare to the current instance.</param>
        /// <returns>A signed number indicating the relative values of this instance and the value parameter.</returns>
        public int CompareTo(FuzzyDateRange value)
        {
            var fromCompare = From.CompareTo(value.From);

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

            return(To.CompareTo(value.To));
        }
コード例 #6
0
 private void Validate()
 {
     if (From == null || To == null)
     {
         throw new Exceptions.ValidationException("Start date and/or End date is null!");
     }
     if (From.CompareTo(To) > 0)
     {
         throw new Exceptions.ValidationException("Start date should be before End date!");
     }
 }
コード例 #7
0
ファイル: FromToValue.cs プロジェクト: naylamp6/TuringMachine
 /// <summary>
 /// Return if are between from an To
 /// </summary>
 /// <param name="o">Object</param>
 public bool ItsValid(T o)
 {
     if (From.CompareTo(o) <= 0 && To.CompareTo(o) >= 0)
     {
         if (Excludes.Contains(o))
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }
コード例 #8
0
ファイル: StateMachine.cs プロジェクト: Soniclev/vkbot-resume
            public int CompareTo(object obj)
            {
                if (!(obj is TransitCondition))
                {
                    return(-1);
                }
                var o       = (TransitCondition)obj;
                var isEqual = From.CompareTo(o.From) == 0 &&
                              From.CompareTo(o.From) == 0 &&
                              From.CompareTo(o.From) == 0;

                return(isEqual ? 0 : 1);
            }
コード例 #9
0
ファイル: FromToValue.cs プロジェクト: naylamp6/TuringMachine
        /// <summary>
        /// String representation
        /// </summary>
        public override string ToString()
        {
            string ex = "";

            if (Excludes != null)
            {
                ex = string.Join(",", Excludes);
            }

            return
                ((From.CompareTo(To) == 0 ? From.ToString() : From.ToString() + " - " + To.ToString())
                 + (ex == "" ? "" : "![" + ex + "]"));
        }
コード例 #10
0
        public int CompareTo(T other)
        {
            if (To.CompareTo(other) < 0)
            {
                return(-1);
            }

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

            return(0);
        }
コード例 #11
0
        private bool IsInLeftBoundary(TValue value)
        {
            switch (LeftBoundaryType)
            {
            case IntervalBoundaryType.Open:
                return(From.CompareTo(value) < 0);

            case IntervalBoundaryType.Closed:
                return(From.CompareTo(value) <= 0);

            default:
                throw new NotImplementedException($"Handling {LeftBoundaryType.GetType().FullName}.{LeftBoundaryType} is not implemented.");
            }
        }
コード例 #12
0
 /// <summary>
 /// Returns -1 if this range's From is less than the other, 1 if greater.
 /// If both are equal, To is compared, 1 if greater, -1 if less.
 /// 0 if both ranges are equal.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public int CompareTo(Range <T> other)
 {
     if (From.CompareTo(other.From) < 0)
     {
         return(-1);
     }
     if (From.CompareTo(other.From) > 0)
     {
         return(1);
     }
     if (To.CompareTo(other.To) < 0)
     {
         return(-1);
     }
     return(To.CompareTo(other.To) > 0 ? 1 : 0);
 }
コード例 #13
0
    public int CompareTo(SpriteLease other)
    {
        if (ReferenceEquals(this, other))
        {
            return(0);
        }
        if (other is null)
        {
            return(1);
        }
        var fromComparison = From.CompareTo(other.From);

        if (fromComparison != 0)
        {
            return(fromComparison);
        }
        return(To.CompareTo(other.To));
    }
コード例 #14
0
ファイル: Edge.cs プロジェクト: n-sutter/wumpus
        public int CompareTo(Edge <T> other)
        {
            int result = 0;

            //Don't compare weights unless both edges have a weight
            if (other.weight != double.PositiveInfinity && this.weight != double.PositiveInfinity)
            {
                result = Weight.CompareTo(other.Weight);
            }

            //What if the edges have the same weight
            if (result == 0)
            {
                result = From.CompareTo(other.From);
                if (result == 0)
                {
                    result = To.CompareTo(other.To);
                }
            }
            return(result);
        }
コード例 #15
0
ファイル: VyQuery.cs プロジェクト: AlfHou/Vy-Lowfare
        // Needed for IMemoryCache equality check
        public bool Equals([AllowNull] VyQuery other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            var toEqual = To.CompareTo(other.To);

            if (toEqual != 0)
            {
                return(false);
            }

            var fromEqual = From.CompareTo(other.From);

            if (fromEqual != 0)
            {
                return(false);
            }

            // Don't compare time of day.
            var queryTime    = DateTime.Parse(Time);
            var queryTimeDay = new DateTime(queryTime.Year, queryTime.Month, queryTime.Day);

            var compareToTime    = DateTime.Parse(other.Time);
            var compareToTimeDay = new DateTime(compareToTime.Year, compareToTime.Month, compareToTime.Day);

            var timeEqual = queryTimeDay.CompareTo(compareToTimeDay);

            if (timeEqual != 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #16
0
ファイル: Range.cs プロジェクト: samvasta/Budget-CLI
        public override string ToString()
        {
            int comparison = From.CompareTo(To);

            if (comparison == 0)
            {
                //From == To
                return(From.ToString());
            }
            else if (comparison < 0)
            {
                //From < To
                StringBuilder sb = new StringBuilder();
                if (IsFromInclusive)
                {
                    sb.Append('[');
                }
                else
                {
                    sb.Append('(');
                }

                sb.Append(From.ToString()).Append(", ").Append(To.ToString());
                if (IsToInclusive)
                {
                    sb.Append(']');
                }
                else
                {
                    sb.Append(')');
                }
                return(sb.ToString());
            }
            else
            {
                return($"Invalid Range: {From} is greater than {To}");
            }
        }
コード例 #17
0
        /// <summary>
        /// Gets the length of this range. For a date range, use the TimeOfDay property of the returned date time.
        /// </summary>
        public T GetLength()
        {
            if (From.CompareTo(To) > 0)
            {
                throw new InvalidOperationException("'from' should be smaller than or equal to 'To' value in a range.");
            }

            var    fromValue = (object)From;
            var    toValue   = (object)To;
            object result;

            if (typeof(T) == typeof(int))
            {
                result = (int)toValue - (int)fromValue;
            }
            else if (typeof(T) == typeof(double))
            {
                result = (double)toValue - (double)fromValue;
            }
            else if (typeof(T) == typeof(long))
            {
                result = (long)toValue - (long)fromValue;
            }
            else if (typeof(T) == typeof(decimal))
            {
                result = (decimal)toValue - (decimal)fromValue;
            }
            else if (typeof(T) == typeof(DateTime))
            {
                result = new DateTime(1900, 1, 1).Add((DateTime)toValue - (DateTime)fromValue);
            }
            else
            {
                throw new NotSupportedException("GetLength() is not supported on type: " + typeof(T).FullName);
            }

            return((T)result);
        }
コード例 #18
0
ファイル: Range.cs プロジェクト: IvanenkoPetr/TombOfMask
 /// <summary>
 /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
 /// </summary>
 /// <param name="other">An object to compare with this instance.</param>
 /// <returns>
 /// Returns -1 if this range's From is less than the other, 1 if greater. If both are equal, To is compared, 1 if greater, -1 if less. 0 if both ranges are equal.
 /// </returns>
 public int CompareTo(Range <T> other)
 {
     if (From.CompareTo(other.From) < 0)
     {
         return(-1);
     }
     else if (From.CompareTo(other.From) > 0)
     {
         return(1);
     }
     else if (To.CompareTo(other.To) < 0)
     {
         return(-1);
     }
     else if (To.CompareTo(other.To) > 0)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
コード例 #19
0
        public int CompareTo(RentalBO other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var idComparison = Id.CompareTo(other.Id);

            if (idComparison != 0)
            {
                return(idComparison);
            }
            var fromComparison = From.CompareTo(other.From);

            if (fromComparison != 0)
            {
                return(fromComparison);
            }
            return(To.CompareTo(other.To));
        }
コード例 #20
0
        public int CompareTo(Interval <T> other)
        {
            if (From.CompareTo(other.From) < 0)
            {
                return(-1);
            }

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

            if (To.CompareTo(other.To) < 0)
            {
                return(1);
            }

            if (To.CompareTo(other.To) > 0)
            {
                return(-1);
            }

            return(0);
        }
コード例 #21
0
ファイル: Range.cs プロジェクト: navoznov/AdventOfCode2018
 public bool HasIntersectionWith(Range <T> second)
 {
     return(From.CompareTo(second.From) <= 0 && To.CompareTo(second.To) >= 0 ||
            From.CompareTo(second.From) <= 0 && To.CompareTo(second.From) > 0 ||
            From.CompareTo(second.To) < 0 && To.CompareTo(second.To) >= 0);
 }
コード例 #22
0
ファイル: RangeBase.cs プロジェクト: vhurryharry/Konekta
 public int CompareTo(RangeBase <TRangeType> other)
 {
     return(From.CompareTo(other?.From));
 }
コード例 #23
0
 public bool Contains(T t)
 {
     return(From.CompareTo(t) <= 0 && To.CompareTo(t) > 0);
 }
コード例 #24
0
 public bool Contains(T point)
 {
     return(From.CompareTo(point) <= 0 &&
            To.CompareTo(point) >= 0);
 }
コード例 #25
0
        /// <summary>
        /// Sammenlikner to TimePeriode objekter for sortering
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public int CompareTo(TimePeriod other)
        {
            var result = From.CompareTo(other.From);

            return(result != 0 ? result : To.CompareTo(other.To));
        }
コード例 #26
0
ファイル: Period.cs プロジェクト: nagaokambeyond/PeriodDotNet
 public bool Content(T obj)
 {
     return(From.CompareTo(obj) <= 0 && To.CompareTo(obj) >= 0);
 }
コード例 #27
0
 public bool Contains(Interval <T> other)
 {
     return(From.CompareTo(other.From) <= 0 &&
            To.CompareTo(other.To) >= 0);
 }
コード例 #28
0
 public bool Overlaps(IRange <T> other)
 {
     return(From.CompareTo(other.To) == -1 && To.CompareTo(other.From) == 1);
 }
コード例 #29
0
 public V Other(V either)
 {
     return(From.CompareTo(either) == 0 ? To : From);
 }
コード例 #30
0
 public bool Overlaps(Interval <T> other)
 {
     return(From.CompareTo(other.To) <= 0 &&
            To.CompareTo(other.From) >= 0);
 }