This is a netbeans8.2 (dev 2018 build) example, how to test the priority queue in the SwappyQueue class.
#include <cstdio>
#include <cstdlib>
#include <inttypes.h>
#include <tuple>
#include "../../src/SwappyQueue.hpp"
using namespace std;
#define ITEMLIMIT 16384
int main(
int argc,
char** argv) {
bool exi;
uint64_t key = 0;
int d = 1;
d = rand()%50;
e.
prio = 5 + rand()%1000;
if (pq->
set(q, e) ==
false) {
printf("Update %6" PRIu64 "\n", q);
} else {
++key;
printf("Insert %6" PRIu64 " (size %" PRIu64 ")\n", q, key);
}
if (d == 0) {
printf(" Delete %6" PRIu64 " (size %" PRIu64 ")\n", q, --key);
}
}
printf("\nrun pop() now!\n\n");
if (exi == false) {
} else {
printf(
"%5lu key: %" PRIu64
" prio: %" PRIu64
" data: %lf\n", i+1, key, e.
prio, e.
data);
}
}
delete(pq);
return 0;
}
SwappyQueue< uint64_t, double > SwKuh
Definition: SwappyQueueTest_main.cpp:16
#define ITEMLIMIT
Definition: SwappyQueueTest_main.cpp:9
int main(int argc, char **argv)
Definition: SwappyQueueTest_main.cpp:18
Definition: SwappyQueue.hpp:43
void del(TKEY key)
Definition: SwappyQueue.hpp:137
bool set(TKEY key, Item &item)
Definition: SwappyQueue.hpp:113
bool top(TKEY &resultkey, Item &result)
Definition: SwappyQueue.hpp:96
Definition: SwappyQueue.hpp:48
uint64_t prio
Definition: SwappyQueue.hpp:50
TVALUE data
Definition: SwappyQueue.hpp:49