-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestTournamentTree.cpp
32 lines (31 loc) · 963 Bytes
/
TestTournamentTree.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "Buffer.h"
#include "TournamentTree.h"
#include "utils.h"
#include <memory>
#include <vector>
int main (int argc, char * argv [])
{
RowSize recordSize = 20;
u_int8_t recordCount = 10;
Buffer * buffer = new Buffer(recordCount, recordSize);
std::vector<byte *> records;
for (u_int8_t i = 0; i < recordCount; i++) {
buffer->fillRandomly();
// records.push_back(buffer->getRow(i));
}
TournamentTree * tree = new TournamentTree(records, recordSize);
tree->printTree();
u_int16_t bufferNum = tree->peekTopBuffer();
printf("Peeked %d\n", bufferNum);
byte * newRecord = (byte *) malloc(recordSize * sizeof(byte));
std::copy(records.front(), records.front() + recordSize, newRecord);
tree->pushAndPoll(newRecord);
tree->printTree();
for (int i = 0; i < recordCount; i++) {
tree->poll();
tree->printTree();
}
delete tree;
free(newRecord);
delete buffer;
}