public PriorityQueue(PriorityQueueOrder priority) { if (priority == PriorityQueueOrder.MaxPriority) { this.heap = new MaxBinaryHeap <T>(); } else { this.heap = new MinBinaryHeap <T>(); } }
/// <summary>Initializes a new instance of <see cref="PriorityQueue{T}"/> which is ordered by /// ascending or descending priority value and has the specified initial capacity.</summary> /// <param name="capacity">The number of elements that the new <see cref="PriorityQueue{T}"/> can initially store.</param> /// <param name="order">Specifies whether the priority queue is ordered by ascending or descending priority value.</param> public PriorityQueue(int capacity, PriorityQueueOrder order = PriorityQueueOrder.Ascending) { switch (order) { case PriorityQueueOrder.Ascending: _heap = new MaxHeap <PriorityQueueNode <T> >(capacity); break; case PriorityQueueOrder.Descending: _heap = new MinHeap <PriorityQueueNode <T> >(capacity); break; default: throw new ArgumentOutOfRangeException(nameof(order), order, null); } }