aboutsummaryrefslogtreecommitdiff
path: root/src/tests/heap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/heap.cpp')
-rw-r--r--src/tests/heap.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tests/heap.cpp b/src/tests/heap.cpp
index daa0356..ae130ec 100644
--- a/src/tests/heap.cpp
+++ b/src/tests/heap.cpp
@@ -8,7 +8,10 @@
8#include <stdlib.h> 8#include <stdlib.h>
9#include <stdio.h> 9#include <stdio.h>
10 10
11#include "bu/formatter.h"
11#include "bu/heap.h" 12#include "bu/heap.h"
13#include "bu/fstring.h"
14#include "bu/file.h"
12 15
13typedef struct num 16typedef struct num
14{ 17{
@@ -35,8 +38,18 @@ typedef struct num
35 } 38 }
36} num; 39} num;
37 40
41void printHeap( Bu::Heap<Bu::FString> &h, int j )
42{
43 Bu::FString sFName;
44 sFName.format("graph-step-%02d.dot", j );
45 Bu::File fOut( sFName, Bu::File::WriteNew );
46 Bu::Formatter f( Bu::File );
47 //h.print( f );
48}
49
38int main() 50int main()
39{ 51{
52 /*
40 Bu::Heap<num> hNum; 53 Bu::Heap<num> hNum;
41 54
42 for( int j = 0; j < 30; j++ ) 55 for( int j = 0; j < 30; j++ )
@@ -53,6 +66,46 @@ int main()
53 hNum.dequeue(); 66 hNum.dequeue();
54 } 67 }
55 printf("\n"); 68 printf("\n");
69*/
70 Bu::Heap<Bu::FString> hStr;
71 int j = 0;
72
73 hStr.enqueue("George");
74 printHeap( hStr, j++ );
75 hStr.enqueue("Sam");
76 printHeap( hStr, j++ );
77 hStr.enqueue("Abby");
78 printHeap( hStr, j++ );
79 hStr.enqueue("Zorro");
80 printHeap( hStr, j++ );
81 hStr.enqueue("Brianna");
82 printHeap( hStr, j++ );
83 hStr.enqueue("Kate");
84 printHeap( hStr, j++ );
85 hStr.enqueue("Soggy");
86 printHeap( hStr, j++ );
87
88 while( !hStr.isEmpty() )
89 {
90 printf("\"%s\" ", hStr.dequeue().getStr() );
91 printHeap( hStr, j++ );
92 }
93 printf("\n");
94
95 Bu::List<Bu::FString> lStr;
96
97 lStr.insertSorted("George");
98 lStr.insertSorted("Sam");
99 lStr.insertSorted("Abby");
100 lStr.insertSorted("Zorro");
101 lStr.insertSorted("Brianna");
102 lStr.insertSorted("Kate");
103 lStr.insertSorted("Soggy");
104 for( Bu::List<Bu::FString>::iterator i = lStr.begin(); i; i++ )
105 {
106 printf("\"%s\" ", (*i).getStr() );
107 }
108 printf("\n");
56 109
57 return 0; 110 return 0;
58} 111}