forked from leo000leo/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree_element.h
More file actions
61 lines (56 loc) · 1.77 KB
/
Copy pathtree_element.h
File metadata and controls
61 lines (56 loc) · 1.77 KB
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
//
// tree_element
// Algorithm
//
// Created by dtysky on 16/11/19.
// Copyright © 2016 [email protected]. All rights reserved.
//
#ifndef ALGORITHM_TREE_ELEMENTS_H
#define ALGORITHM_TREE_ELEMENTS_H
#include <cstdio>
#include <iostream>
namespace data_structures {
template <typename Key, typename Value>
struct TreeElement {
public:
Key key;
Value value;
TreeElement() {}
TreeElement(const Key& k, const Value& v) {
key = k;
value = v;
}
TreeElement(const TreeElement<Key, Value>& element) {
key = element.key;
value = element.value;
}
TreeElement<Key, Value>& operator=(const TreeElement<Key, Value>& element) {
key = element.key;
value = element.value;
return *this;
}
bool operator==(const TreeElement<Key, Value>& element) const {
return key == element.key;
}
bool operator!=(const TreeElement<Key, Value>& element) const {
return key != element.key;
}
bool operator>(const TreeElement<Key, Value>& element) const {
return key > element.key;
}
bool operator<(const TreeElement<Key, Value>& element) const {
return key < element.key;
}
bool operator>=(const TreeElement<Key, Value>& element) const {
return key >= element.key;
}
bool operator<=(const TreeElement<Key, Value>& element) const {
return key <= element.key;
}
friend std::ostream &operator<<(std::ostream &out, const TreeElement<Key, Value> &element) {
out<< element.key << ":" << element.value;
return out;
};
};
}
#endif //ALGORITHM_TREE_ELEMENTS_H