private IEnumerable <Ride> GetBestScore(int n) { var comparer = Ride.CreateScoreComparer(_car, _problem); var heap = new MinHeap <Ride>(comparer); foreach (var ride in _availableRides) { if (_car.CanMakeIt(ride) && (heap.Count < n || comparer.Compare(heap.Min, ride) < 0)) { heap.Add(ride); if (heap.Count > n) { heap.ExtractMin(); } } } return(heap); }
/// <summary> /// Insert the value. /// </summary> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentException"></exception> public void Add(T item) => minHeap.Add(item);