private static void TestHeapIntWithComparator() { var comper = new Comper(); var heap = new BinaryHeap <int>(comper); heap.Add(4); heap.Add(7); heap.Add(1); heap.Add(777); heap.Add(12); heap.Add(3); heap.RemoveTop(); Console.WriteLine(heap.GetTopElement()); }
private static void TestHeap1() { var heap = new BinaryHeap <int>(); heap.Add(4); heap.Add(7); heap.Add(1); heap.Add(777); heap.Add(12); heap.Add(3); heap.RemoveTop(); heap.RemoveTop(); Console.WriteLine(heap.GetTopElement()); }
public static void Main(string[] args) { BinaryHeap <int> priorityQueue = new BinaryHeap <int>(); priorityQueue.Add(4); priorityQueue.Add(6); priorityQueue.Add(9); priorityQueue.Add(22); priorityQueue.Add(5); priorityQueue.Add(3); priorityQueue.Add(13); priorityQueue.Add(37); priorityQueue.Add(100); priorityQueue.Add(46); while (priorityQueue.Count > 0) { Console.WriteLine(priorityQueue.Remove()); } }
/// <summary> /// Constructor using predefined priority rules /// </summary> /// <param name="compararer">The compararer which will set the priority rules</param> public PriorityQueue(Comparer <T> compararer) { this.queue = new BinaryHeap <T>(compararer); }
public PriorityQueue() : this(Comparer <T> .Default) { data = new BinaryHeap <T>(this.Comparer); }
public PriorityQueue() { this.data = new BinaryHeap <T>(); }
public PriorityQueue(Comparison <T> comparison) { this.data = new BinaryHeap <T>(4, comparison); }