-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.h
61 lines (39 loc) · 1011 Bytes
/
Node.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
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by maxi on 30.04.20.
//
#ifndef ONESHOT_CADICAL_NODE_H
#define ONESHOT_CADICAL_NODE_H
#include <memory>
#include <atomic>
#include <iostream>
class Tree;
class Node {
friend class Tree;
public:
Node(Node *parent, int lit) : parent{parent}, lit{lit}, depth{parent->depth + 1} {};
Node() = default;
int getLit();
int getDepth();
int getId();
Node *getParent();
void log(std::ostream &logFile);
std::atomic<int> iterations{0};
protected:
static std::atomic<int> s_id;
private:
int id{++s_id};
const int lit = 0;
const int depth = 1;
Node *parent = nullptr;
Node *neighbour = nullptr;
// Need to use pointers because no forward declaration possible
std::unique_ptr<Node> left = nullptr;
std::unique_ptr<Node> right = nullptr;
int solverCounter = 0;
int visits = 0;
bool isLeaf = true;
void extend(int newLit);
bool wasPruned = false;
void prune();
};
#endif //ONESHOT_CADICAL_NODE_H