From e2a10c7b77b03bacf4d8b8dcf08f8f8f47628314 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 19 Feb 2008 09:24:27 +0000 Subject: Bu::Heap is a real class, it works great, except it doesn't grow right now. I'm thinking the heap should add one layer to the binary tree each time it grows, which means double+1 each time. The Bu::ItoHeap will be implemented as soon as the rest of Bu::Heap is done. Also, I finally added bu/util.h which is mainly handy template functions like Bu::swap, Bu::min, Bu::max, and Bu::mid. A few more may be added. --- src/tests/heap.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/tests/heap.cpp (limited to 'src/tests') diff --git a/src/tests/heap.cpp b/src/tests/heap.cpp new file mode 100644 index 0000000..e93749f --- /dev/null +++ b/src/tests/heap.cpp @@ -0,0 +1,29 @@ +#include +#include + +#include "bu/heap.h" + +int main() +{ + Bu::Heap hInt; + + for( int j = 0; j < 15; j++ ) + { + int r = rand()%10; + printf("Pushing: %d, top: ", r ); + hInt.push( r ); + printf("%d\n", hInt.peek() ); + } + + for( int j = 0; j < 15; j++ ) + { + printf("%d ", hInt.peek() ); + hInt.pop(); + } + printf("\n"); + +// hInt.print(); + + return 0; +} + -- cgit v1.2.3