-
Notifications
You must be signed in to change notification settings - Fork 1
/
Reservoir.h
48 lines (36 loc) · 1004 Bytes
/
Reservoir.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "config.h"
#include <algorithm>
#include <iostream>
#include <omp.h>
#define EMPTY -1
class Reservoir {
private:
// The size of the reservoir.
unsigned int size;
// The number of attempted insertions.
unsigned int count;
// Lock for thread safety.
omp_lock_t *lock;
// The array to store the contents of the reservoir.
unsigned int *reservoir;
public:
// Constructor.
Reservoir(unsigned int size);
// Constructor.
Reservoir();
// Adds an item to the reservoir.
void add(unsigned int item);
// Copies the contents of the reservoir into the specified buffer.
void retrieve(unsigned int *buffer);
// Gets the size of the reservoir.
unsigned int get_size();
// Gets the count of the reservoir.
unsigned int get_count();
// Clears the reservoir and resets the count.
void reset();
// Prints the contents of the reservoir.
void view();
// Destructor.
~Reservoir();
};