Beispiel #1
0
        public int CompareTo(object o)
        {
            KeyStruct key    = o as KeyStruct;
            int       result = Year.CompareTo(key.Year);

            if (result != 0)
            {
                return(result);
            }
            result = Month.CompareTo(key.Month);
            if (result != 0)
            {
                return(result);
            }
            result = Day.CompareTo(key.Day);
            if (result != 0)
            {
                return(result);
            }
            result = Hour.CompareTo(key.Hour);
            if (result != 0)
            {
                return(result);
            }
            result = Min.CompareTo(key.Min);
            if (result != 0)
            {
                return(result);
            }
            result = ID.CompareTo(key.ID);
            return(result);
        }
Beispiel #2
0
 public bool IsInside(T value, bool inclusive = true)
 {
     return
         (inclusive
                                 ? Max.CompareTo(value) >= 0 && Min.CompareTo(value) <= 0
                                 : Max.CompareTo(value) > 0 && Min.CompareTo(value) < 0);
 }
Beispiel #3
0
 public bool SameState(DoubleMomentStatistics other)
 {
     return(Min.CompareTo(other.Min) == 0 &&
            Max.CompareTo(other.Max) == 0 &&
            _sum.SameState(other._sum) &&
            base.SameState(other));
 }
Beispiel #4
0
        /// <summary>
        /// Advances the enumerator to the next element of the collection.
        /// </summary>
        /// <returns>
        /// True if the enumerator was successfully advanced to the next
        /// element; false if the enumerator has passed the end of the
        /// collection.
        /// </returns>
        public override Boolean MoveNext()
        {
            if (SourcePipe == null)
            {
                return(false);
            }

            if (SourcePipe.MoveNext())
            {
                _CurrentElement = SourcePipe.Current;

                if (Min.CompareTo(_CurrentElement) > 0)
                {
                    SideEffect1 = _CurrentElement;
                }

                if (Max.CompareTo(_CurrentElement) < 0)
                {
                    SideEffect2 = _CurrentElement;
                }

                return(true);
            }

            return(false);
        }
Beispiel #5
0
 public bool IsBelow(T value, bool inclusive = true)
 {
     return
         (inclusive
                                 ? Min.CompareTo(value) >= 0
                                 : Min.CompareTo(value) > 0);
 }
Beispiel #6
0
        public T Clamp(T value)
        {
            var result = Min.CompareTo(value) > 0 ? Min : value;

            result = Max.CompareTo(result) < 0 ? Max : result;
            return(result);
        }
Beispiel #7
0
 public bool IsBelow(T value, bool strictly = false)
 {
     return
         (strictly
                                 ? Min.CompareTo(value) > 0
                                 : Min.CompareTo(value) >= 0);
 }
Beispiel #8
0
 public bool IsInside(T value, bool strictly = false)
 {
     return
         (strictly
                                 ? Max.CompareTo(value) > 0 && Min.CompareTo(value) < 0
                                 : Max.CompareTo(value) >= 0 && Min.CompareTo(value) <= 0);
 }
Beispiel #9
0
        /// <summary>
        /// Advances the enumerator to the next element of the collection.
        /// </summary>
        /// <returns>
        /// True if the enumerator was successfully advanced to the next
        /// element; false if the enumerator has passed the end of the
        /// collection.
        /// </returns>
        public override Boolean MoveNext()
        {
            if (_InternalEnumerator == null)
            {
                return(false);
            }

            if (_InternalEnumerator.MoveNext())
            {
                _CurrentElement = _InternalEnumerator.Current;

                if (Min.CompareTo(_CurrentElement) > 0)
                {
                    SideEffect1 = _CurrentElement;
                }

                if (Max.CompareTo(_CurrentElement) < 0)
                {
                    SideEffect2 = _CurrentElement;
                }

                return(true);
            }

            return(false);
        }
Beispiel #10
0
        public void Summarize(object value)
        {
            string myvalue = value.ToString();

            Count++;
            if (Count > 1)
            {
                if (Function == SummaryFunctionsText.Max)
                {
                    Max = (Max.CompareTo(myvalue) > 0) ? Max : myvalue;
                }
                else if (Function == SummaryFunctionsText.Min)
                {
                    Min = (Min.CompareTo(myvalue) > 0) ? myvalue : Min;
                }
            }
            else
            {
                if (Function == SummaryFunctionsText.Max)
                {
                    Max = myvalue;
                }
                else if (Function == SummaryFunctionsText.Min)
                {
                    Min = myvalue;
                }
            }
        }
Beispiel #11
0
 public override bool Equals(object other)
 {
     if (other == null || GetType() != other.GetType())
     {
         return(false);
     }
     return(Min.CompareTo(((DoubleRange)other).Min) == 0 && Max.CompareTo(((DoubleRange)other).Max) == 0);
 }
        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        /// <inheritdoc/>
        public override ArgumentResult Parse(IReadOnlyList <string> args, ref int index)
        {
            if (Min.CompareTo(Max) > 0)
            {
                throw new ArgumentException("min must be less than or equal to max.");
            }

            return(base.Parse(args, ref index));
        }
Beispiel #13
0
        /// <inheritdoc />
        public override string ToString()
        {
            var result = new StringBuilder();

            result.Append(Min.CompareTo(IncludedMin) == 0 ? '[' : ')');
            result.Append(Min);
            result.Append("..");
            result.Append(Max);
            result.Append(Max.CompareTo(IncludedMax) == 0 ? ']' : '(');
            return(result.ToString());
        }
Beispiel #14
0
 public bool Includes(T value)
 {
     if (Min.CompareTo(value) > 0)
     {
         return(false);
     }
     if (Max.CompareTo(value) < 0)
     {
         return(false);
     }
     return(true);
 }
Beispiel #15
0
        // Intersect two ranges to find the smallest shared set of versions
        // Returns null if the two ranges do not intersect
        // Max == null means no upper bound on version
        public UnityVersionRange Intersect(UnityVersionRange other)
        {
            var highestLow = Min.CompareTo(other.Min) > 0 ? Min : other.Min;
            var lowestHigh = Max == null? other.Max : Max.CompareTo(other.Max) < 0 ? Max : other.Max;

            if (highestLow.CompareTo(lowestHigh) > 0)
            {
                return(null);
            }

            return(new UnityVersionRange(highestLow, lowestHigh));
        }
        /// <summary>
        /// Returns the intersection/overlapping
        /// range from this and the supplied range
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        public Range <T> Intersection(Range <T> range)
        {
            var minMin = Min.CompareTo(range.Min) <= 0 ? range.Min : Min;
            var minMax = Max.CompareTo(range.Max) >= 0 ? range.Max : Max;

            if (minMin.CompareTo(minMax) > 0)
            {
                throw new ArgumentException("No intersection found");
            }

            return(new Range <T>(minMin, minMax));
        }
Beispiel #17
0
 internal Range <T> Intersect(Range <T> other)
 {
     if (IsOverlapped(other))
     {
         var newMin = Min.CompareTo(other.Min) > 0 ? Min : other.Min;
         var newMax = Max.CompareTo(other.Max) < 0 ? Max : other.Max;
         return(new Range <T>(newMin, newMax));
     }
     else
     {
         return(null);
     }
 }
Beispiel #18
0
 public void SetRange(T tMin, T tMax)
 {
     if (Min.CompareTo(Max) <= 0)
     {
         _min = tMin;
         _max = tMax;
     }
     else
     {
         _min = tMax;
         _max = tMin;
     }
 }
Beispiel #19
0
        protected virtual void OnMinValueChanged()
        {
            Task.Run(() =>
            {
                var minValue = FromString(MinValueRaw);
                var maxValue = FromString(MaxValueRaw);

                var minCompareValue = Min.CompareTo(Max) < 0 ? Min : Max;
                minCompareValue     = minCompareValue.CompareTo(minValue) < 0 ? minValue : minCompareValue;
                minCompareValue     = minCompareValue.CompareTo(maxValue) > 0 ? maxValue : minCompareValue;

                InvokeOnMainThread(() => Min = minCompareValue);

                SelectedValue.MinValue = ToRawString(Min);
            });
        }
Beispiel #20
0
        /// <summary>
        /// Process the incoming message and return an outgoing message.
        /// </summary>
        /// <param name="MessageIn">The incoming message.</param>
        /// <param name="MessageOut">The outgoing message.</param>
        protected override Boolean ProcessMessage(TMessage MessageIn, out TMessage MessageOut)
        {
            MessageOut = MessageIn;

            if (Min.CompareTo(MessageIn) > 0)
            {
                SideEffect1 = MessageIn;
            }

            if (Max.CompareTo(MessageIn) < 0)
            {
                SideEffect2 = MessageIn;
            }

            return(true);
        }
Beispiel #21
0
        /// <summary>
        /// Sets Min and Max properties according to given range type and current value
        /// </summary>
        /// <param name="rangeKind">The type of range</param>
        public void SetRange(RangeKind rangeKind)
        {
            var rangeValue = _ranges[rangeKind];

            Min = Minus(Value, rangeValue);
            Max = Plus(Value, rangeValue);
            // check if we are outside the (DefaultMin, DefaultMax)
            if (Min.CompareTo(DefaultMin) < 0)
            {
                Min = DefaultMin;
            }
            if (Max.CompareTo(DefaultMax) > 0)
            {
                Max = DefaultMax;
            }
        }
Beispiel #22
0
        public int CompareTo(TimeRange other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var minSecondsComparison = Min.CompareTo(other.Min);

            if (minSecondsComparison != 0)
            {
                return(minSecondsComparison);
            }
            return(Max.CompareTo(other.Max));
        }
Beispiel #23
0
 /// <summary>
 /// checks if the given value is in range of this entry
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public virtual bool InRange(TDimension value)
 {
     if (hasValue)
     {
         if (Value == null && value == null)
         {
             return(true);
         }
         else if (Value == null)
         {
             return(false);
         }
         else
         {
             return(Value.CompareTo(value) == 0);
         }
     }
     else
     {
         return(Min.CompareTo(value) <= 0 && Max.CompareTo(value) > 0);
     }
 }
        public List <T> CheckOverlapping(Range <T> other)
        {
            if (Min.CompareTo(other.Max) <= 0 && other.Min.CompareTo(Max) <= 0)
            {
                T begin = Min;
                T end   = Max;

                if (Max.CompareTo(other.Max) >= 0)
                {
                    begin = other.Max;
                }
                if (Min.CompareTo(other.Min) <= 0)
                {
                    end = other.Min;
                }

                List <T> res = new List <T>();
                res.Add(begin);
                res.Add(end);
                return(res);
            }
            return(null);
        }
Beispiel #25
0
        /// <summary>
        /// Validates the contents of a field. If an error is found, the <see cref="Field.Error"/> property is set accordingly.
        /// The <see cref="Field.Error"/> property is not cleared if no error is found.
        /// </summary>
        /// <param name="Field">Field</param>
        /// <param name="DataType">Data type of field.</param>
        /// <param name="Parsed">Parsed values.</param>
        /// <param name="Strings">String values.</param>
        public override void Validate(Field Field, DataType DataType, object[] Parsed, string[] Strings)
        {
            base.Validate(Field, DataType, Parsed, Strings);

            IComparable Min;
            IComparable Max;

            if (string.IsNullOrEmpty(this.min))
            {
                Min = null;
            }
            else
            {
                Min = DataType.Parse(this.min) as IComparable;
            }

            if (string.IsNullOrEmpty(this.max))
            {
                Max = null;
            }
            else
            {
                Max = DataType.Parse(this.max) as IComparable;
            }

            foreach (object Obj in Parsed)
            {
                if (Min != null && Min.CompareTo(Obj) > 0)
                {
                    Field.Error = "Value out of range.";
                }
                else if (Max != null && Max.CompareTo(Obj) < 0)
                {
                    Field.Error = "Value out of range.";
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// Compares <b><i>this</i></b> to <paramref name="other"/> using <see cref="CompareTo"/> calls against multiple properties:
        /// <li><see cref="Min"/></li>
        /// <li><see cref="Max"/></li>
        /// <li><see cref="Average"/></li>
        /// Returns -1 or 1 if <b>any</b> properties return that value and <b>none</b> return the other;
        /// otherwise, returns 0.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public int CompareTo([NotNull] AggregateExecutionTime other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            return(Average.CompareTo(other.Average));

            var minCompare = Min.CompareTo(other.Min);
            var maxCompare = Max.CompareTo(other.Max);
            var avgCompare = Average.CompareTo(other.Average);

            var compares = new int[] { minCompare, maxCompare, avgCompare };

            Console.WriteLine(
                new Dictionary <object, object>()
            {
                [$"Min: {Min}, {other.Min}"]         = minCompare,
                [$"Max: {Max}, {other.Max}"]         = maxCompare,
                [$"Avg: {Average}, {other.Average}"] = avgCompare
            }.Prettify()
                );
            if (compares.Any(it => it > 0) && compares.All(it => it >= 0))
            {
                return(1);
            }
            else if (compares.Any(it => it < 0) && compares.All(it => it <= 0))
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Beispiel #27
0
 public int CompareTo(Bucket other)
 {
     return(Min.CompareTo(other.Min));
 }
Beispiel #28
0
 // Compare and sort based on the lowest version number
 public int CompareTo(UnityVersionRange other) => Min.CompareTo(other.Min);
Beispiel #29
0
 public int CompareTo(IntRange other)
 {
     return(Min.CompareTo(other.Min));
 }
Beispiel #30
0
 public bool IsOverlapped(Range <T> other)
 {
     return(Min.CompareTo(other.Max) < 0 && other.Min.CompareTo(Max) < 0);
 }