C++ Heap Template
For some reason heap container is missing in C++ standard template library. Instead they have provided push_heap, pop_heap and make_heap opeartion as seperate functions, which is obviating gory details of a simple container and so unnecessary. I've always wished that there be a simple container like rb_tree, which can manage the property. So here it is-
C++ SourceClick here to download the code DescriptionThis is very simple container following heap property. It provides two basic classes MinHeap and MaxHeap. This template can be inherited to create more complex templates like treap.
ExampleMinHeap<int> my_heap; my_heap.push(10); int element = my_heap.pop(); Disclaimer/////////////////////////////////////////////////////////////////// // Copyright (c) 2006 Rohit Sharma. All rights reserved. // This program is free software; you can redistribute it and/or // modify it under the terms as GNU General Public License. /////////////////////////////////////////////////////////////////// |