The SwappyItems Key-Values Store
Macros | Typedefs | Functions
SwappyQueueTest_main.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <inttypes.h>
#include <tuple>
#include "../../src/SwappyQueue.hpp"

Macros

#define ITEMLIMIT   16384
 

Typedefs

typedef SwappyQueue< uint64_t, double > SwKuh
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ ITEMLIMIT

#define ITEMLIMIT   16384

Typedef Documentation

◆ SwKuh

typedef SwappyQueue<uint64_t, double> SwKuh

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
Examples
SwappyQueueTest_main.cpp.
18  {
19  SwKuh * pq;
20  pq = new SwKuh();
21  bool exi;
22  uint64_t key = 0;
23 
24  for (uint64_t i = 0; i < ITEMLIMIT; ++i) {
25  int d = 1;
26  d = rand()%50;
27  uint64_t q = rand()%ITEMLIMIT;
28 
29  SwKuh::Item e;
30  e.data = 0.01 * rand();
31  e.prio = 5 + rand()%1000;
32  if (pq->set(q, e) == false) {
33  printf("Update %6" PRIu64 "\n", q);
34  } else {
35  ++key;
36  printf("Insert %6" PRIu64 " (size %" PRIu64 ")\n", q, key);
37  }
38 
39  if (d == 0) {
40  pq->del(q);
41  printf(" Delete %6" PRIu64 " (size %" PRIu64 ")\n", q, --key);
42  }
43  }
44 
45  printf("\nrun pop() now!\n\n");
46  for (uint64_t i = 0; i < ITEMLIMIT; ++i) {
47  SwKuh::Item e;
48  exi = pq->top(key, e);
49  if (exi == false) {
50  i = ITEMLIMIT;
51  } else {
52  printf("%5lu key: %" PRIu64 " prio: %" PRIu64 " data: %lf\n", i+1, key, e.prio, e.data);
53  pq->del(key);
54  }
55  }
56 
57  delete(pq);
58  return 0;
59 }
SwappyQueue< uint64_t, double > SwKuh
Definition: SwappyQueueTest_main.cpp:16
#define ITEMLIMIT
Definition: SwappyQueueTest_main.cpp:9
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