-
Notifications
You must be signed in to change notification settings - Fork 0
/
reducer_bag.h
49 lines (38 loc) · 743 Bytes
/
reducer_bag.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
49
#include <cilk/cilk.h>
#include <cilk/reducer.h>
#include "bag.h"
#ifndef REDUCER_BAG_H_INCLUDED
#define REDUCER_BAG_H_INCLUDED
class BagView {
public:
Bag* bag;
typedef Bag* value_type;
BagView() {
bag = new Bag();
}
void reduce(BagView* bv) {
bag->bag_union(bv->get_value());
}
void insert(int v) {
bag->insert(v);
}
bool is_empty() {
return bag->is_empty();
}
int get_size() {
return bag->get_size();
}
int get_depth() {
return bag->get_depth();
}
Bag* get_value() {
return bag;
}
~BagView() {
delete bag;
}
};
// Monoid class.
//
typedef cilk::monoid_with_view<BagView> BagMonoid;
#endif