aboutsummaryrefslogtreecommitdiff
path: root/src/tests/heap.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
committerMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
commit509d136e9adb60c56369565b9545e613cac3678e (patch)
treef118d676edeae2d5e17f48b32b180d4761b60520 /src/tests/heap.cpp
parent3166bd631a093f42ea44a4b0f4d914cf51518bd4 (diff)
downloadlibbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.gz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.bz2
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.xz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.zip
I've started my campaign to clean up all of the header files in libbu++ as far
as includes go. This required a little bit of reworking as far as archive goes, but I've been planning on changing it aronud for a bit anyway. The final result here is that you may need to add some more includes in your own code, libbu++ doesn't include as many random things you didn't ask for anymore, most of these seem to be bu/hash.h, unistd.h, and time.h. Also, any Archive functions and operators should use ArchiveBase when they can instead of Archive, archivebase.h is a much lighterweight include that will be used everywhere in core that it can be, there are a few classes that actually want a specific archiver to be used, they will use it (such as the nids storage class). So far, except for adding header files, nothing has changed in functionality, and no other code changes should be required, although the above mentioned archive changeover is reccomended.
Diffstat (limited to '')
-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}