MSTParser.ValueIndexPair.CompareTo C# (CSharp) Méthode

CompareTo() public méthode

public CompareTo ( ValueIndexPair other ) : int
other ValueIndexPair
Résultat int
        public int CompareTo(ValueIndexPair other)
        {
            if (Val < other.Val)
                return -1;
            if (Val > other.Val)
                return 1;
            return 0;
        }

Usage Example

 public void Add(ValueIndexPair e)
 {
     // bubble up:
     int where = _currentSize + 1; // new last place
     while (e.CompareTo(_theArray[Parent(where)]) > 0)
     {
         _theArray[where] = _theArray[Parent(where)];
         where = Parent(where);
     }
     _theArray[where] = e;
     _currentSize++;
 }