c++: Max Heap Template
https://en.wikipedia.org/wiki/Min-max_heap
My simple implementation of max heap.
Change the compare from > to < in below codes, you will get a min heap.
template
class MaxHeap {
public:
MaxHeap() {
size_ = 0;
capacity_ = 2;
heap_ = new T[capacity_];
}
MaxHeap(int capacity) {
if (capacity >= 2) {
heap_ = new T[capacity]