aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-02-19 09:24:27 +0000
committerMike Buland <eichlan@xagasoft.com>2008-02-19 09:24:27 +0000
commite2a10c7b77b03bacf4d8b8dcf08f8f8f47628314 (patch)
tree5745237cd2a340a6a69dc34596ba87c9ba403c84 /src/tests
parent8bbe1d4a61288a2998fbae05ac61ef50a8cfc4e6 (diff)
downloadlibbu++-e2a10c7b77b03bacf4d8b8dcf08f8f8f47628314.tar.gz
libbu++-e2a10c7b77b03bacf4d8b8dcf08f8f8f47628314.tar.bz2
libbu++-e2a10c7b77b03bacf4d8b8dcf08f8f8f47628314.tar.xz
libbu++-e2a10c7b77b03bacf4d8b8dcf08f8f8f47628314.zip
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.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/heap.cpp29
1 files changed, 29 insertions, 0 deletions
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 @@
1#include <stdlib.h>
2#include <stdio.h>
3
4#include "bu/heap.h"
5
6int main()
7{
8 Bu::Heap<int> hInt;
9
10 for( int j = 0; j < 15; j++ )
11 {
12 int r = rand()%10;
13 printf("Pushing: %d, top: ", r );
14 hInt.push( r );
15 printf("%d\n", hInt.peek() );
16 }
17
18 for( int j = 0; j < 15; j++ )
19 {
20 printf("%d ", hInt.peek() );
21 hInt.pop();
22 }
23 printf("\n");
24
25// hInt.print();
26
27 return 0;
28}
29