Ejemplo n.º 1
0
        public void TestCompareToMethodWithIntParam()
        {
            var firstWeight  = new Weight(36);
            var secondWeight = 25;
            var thirdWeight  = 77;
            var fourthWeight = 36;

            Assert.AreEqual(1, firstWeight.CompareTo(secondWeight), "CompareTo method (with integer param) of Weight class does not work properly");
            Assert.AreEqual(-1, firstWeight.CompareTo(thirdWeight), "CompareTo method (with integer param) of Weight class does not work properly");
            Assert.AreEqual(0, firstWeight.CompareTo(fourthWeight), "CompareTo method (with integer param) of Weight class does not work properly");
        }
Ejemplo n.º 2
0
        public void TestCompareToMethodWithWeightParam()
        {
            var firstWeight = new Weight(36);
            var secondWeight = new Weight(25);
            var thirdWeight = new Weight(77);
            var fourthWeight = new Weight(36);

            Assert.AreEqual(1, firstWeight.CompareTo(secondWeight), "CompareTo method (with Weight param) of Weight class does not work properly");
            Assert.AreEqual(-1, firstWeight.CompareTo(thirdWeight), "CompareTo method (with Weight param) of Weight class does not work properly");
            Assert.AreEqual(0, firstWeight.CompareTo(fourthWeight), "CompareTo method (with Weight param) of Weight class does not work properly");
        }
Ejemplo n.º 3
0
        public void CompareTo()
        {
            Weight d1 = new Weight(35, Weight.UnitType.Kg);
            Weight d2 = new Weight(3300, Weight.UnitType.G);

            Assert.AreEqual(d1.CompareTo(d2), 1);
        }
Ejemplo n.º 4
0
        public int CompareTo(WeightedValue <TValue> other)
        {
            var valueComparer = Comparer <TValue> .Default;
            var result        = valueComparer.Compare(Value, other.Value);

            return(result == 0 ? Weight.CompareTo(other.Weight) : result);
        }
Ejemplo n.º 5
0
 public int CompareTo(Edge other)
 {
     if (Weight == other.Weight)
     {
         return(id.CompareTo(other.id));
     }
     return(Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 6
0
            public int CompareTo(HuffmanNode <T> other)
            {
                if (other is null)
                {
                    return(1);
                }

                return(Weight.CompareTo(other.Weight));
            }
Ejemplo n.º 7
0
 public int CompareTo(Job other)
 {
     if (_invariant == other._invariant)
     {
         return(-Weight.CompareTo(other.Weight));
     }
     if (_invariant > other._invariant)
     {
         return(-1);
     }
     return(1);
 }
Ejemplo n.º 8
0
 public int CompareTo(Snippet <T> other)
 {
     if (other == null)
     {
         return(-1);
     }
     if (this.AnnotationMetadata != other.AnnotationMetadata)
     {
         return(0);
     }
     return(Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 9
0
        public int CompareTo(Carriage other)
        {
            var result = string.Compare(Cargo, other.Cargo, StringComparison.Ordinal);

            if (result == 0)
            {
                result = Weight.CompareTo(other.Weight);
                if (result == 0)
                {
                    result = Length.CompareTo(other.Length);
                }
            }

            return(result);
        }
        public int CompareTo(IEdge <TVertex> other)
        {
            if (other == null)
            {
                return(-1);
            }

            bool areNodesEqual = Source.IsEqualTo <TVertex>(other.Source) && Destination.IsEqualTo <TVertex>(other.Destination);

            if (!areNodesEqual)
            {
                return(-1);
            }
            return(Weight.CompareTo(other.Weight));
        }
Ejemplo n.º 11
0
        public int CompareTo(object Obj)
        {
            int     ReturnInt;
            Element el = Obj as Element;

            ReturnInt = Weight.CompareTo(el.Weight);
            if (ReturnInt == 0)
            {
                ReturnInt = Value.CompareTo(el.Value);
            }
            if (ReturnInt == 0)
            {
                ReturnInt = Value.CompareTo(el.Value);
            }
            return(ReturnInt);
        }
Ejemplo n.º 12
0
        public int CompareTo(TermPart other)
        {
            if (other.Path == this.Path)
            {
                var weight = Weight.CompareTo(other.Weight);

                if (weight != 0)
                {
                    return(weight);
                }
                // if same weight, compare by name
                return(this.Name.CompareTo(other.Name));
            }

            return(FullPath.CompareTo(other.FullPath));
        }
Ejemplo n.º 13
0
        public virtual int CompareTo(object obj)
        {
            EbmlGeneric m   = (EbmlGeneric)obj;
            int         res = Weight.CompareTo(m.Weight);

            if (res != 0)
            {
                return(res);
            }
            if (Weight == -1)
            {
                return(InputOffset.CompareTo(m.InputOffset));
            }
            res = Id.CompareTo(m.Id);
            if (res != 0)
            {
                return(res);
            }
            return(InputOffset.CompareTo(m.InputOffset));
        }
Ejemplo n.º 14
0
 public int CompareTo(Plane other)
 {
     if (other == null)
     {
         return(1);
     }
     if (MaxSpeed != other.MaxSpeed)
     {
         return(MaxSpeed.CompareTo(other.MaxSpeed));
     }
     if (MaxCountBomb != other.MaxCountBomb)
     {
         return(MaxCountBomb.CompareTo(other.MaxCountBomb));
     }
     if (Weight != other.Weight)
     {
         return(Weight.CompareTo(other.Weight));
     }
     if (ColorBody != other.ColorBody)
     {
         ColorBody.Name.CompareTo(other.ColorBody.Name);
     }
     return(0);
 }
 public int CompareTo(Shark other)
 {
     if (other == null)
     {
         return(1);
     }
     if (MaxNumberOfVictims != other.MaxNumberOfVictims)
     {
         return(MaxNumberOfVictims.CompareTo(other.MaxNumberOfVictims));
     }
     if (HoursNeededToSleep != other.HoursNeededToSleep)
     {
         return(HoursNeededToSleep.CompareTo(other.HoursNeededToSleep));
     }
     if (Weight != other.Weight)
     {
         return(Weight.CompareTo(other.Weight));
     }
     if (BodyPattern != other.BodyPattern)
     {
         return(BodyPattern.Name.CompareTo(other.BodyPattern.Name));
     }
     return(0);
 }
Ejemplo n.º 16
0
 public int CompareTo(KruskalEdge other)
 {
     return(_isMin ?
            -1 * Weight.CompareTo(other.Weight) :
            Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 17
0
 public virtual int CompareTo(Path _Other)
 {
     return(Weight.CompareTo(_Other.Weight));
 }
Ejemplo n.º 18
0
 public int CompareByWeight(Rule other)
 {
     return(Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 19
0
 public int CompareTo(object obj)
 {
     return(Weight.CompareTo((obj as node).Weight));
 }
Ejemplo n.º 20
0
 public int CompareTo(Edge e)
 {
     return(Weight.CompareTo(e.Weight));
 }
Ejemplo n.º 21
0
 public Int32 CompareTo(T otherWeight)
 {
     return(WeightComparer == null?Weight.CompareTo(otherWeight) :
                WeightComparer.Compare(Weight, otherWeight));
 }
Ejemplo n.º 22
0
 public int CompareTo(BoardState other)
 {
     return(Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 23
0
 public int CompareTo(Edge <T> other)
 {
     return(other == null ? 1 : Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 24
0
 public int CompareTo(Edge <TE, TW> other)
 {
     return(Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 25
0
 public int CompareTo(Item other)
 {
     return(Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 26
0
 int IComparable <AuxNode <TKey, TItem> > .CompareTo(AuxNode <TKey, TItem> other)
 {
     return(Weight.CompareTo(other.Weight));
 }
Ejemplo n.º 27
0
        public int CompareTo(Coin other)
        {
            var weight = Weight.CompareTo(other.Weight);

            return(weight == 0 ? weight : Value.CompareTo(other.Value));
        }