public int CompareTo(HeapNode <TValue>?other) { if (other == null) { return(1); } var diff = Priority.CompareTo(other.Priority); if (diff == 0) { return(InsertOrder.CompareTo(other.InsertOrder)); } return(diff); }
public void Insert(HeapNode <T> value) { Size++; var i = Size - 1; if (i >= _values.Count) { _values.Add(value); } else { _values[i] = value; } while (i != 0 && _values[Parent(i)].CompareTo(_values[i]) == 1) { Swap(i, Parent(i)); i = Parent(i); } }