Skip to content

Commit d753294

Browse files
Add a template util to help create a typical_segment_tree; Release 0.2.2
1 parent da47f7f commit d753294

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

library/mrpython/typical_segment_tree.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,18 @@ template <typename T>
9090
using typical_segment_tree_max = typical_segment_tree<T, max>;
9191
template <typename T>
9292
using typical_segment_tree_min = typical_segment_tree<T, min>;
93+
94+
template <typename NodeStruct> class typical_segment_tree_from_node {
95+
using T = typename NodeStruct::T;
96+
struct MergeFunction {
97+
T operator()(T const& a, T const& b) const {
98+
return NodeStruct::merge_data(a, b);
99+
}
100+
};
101+
typical_segment_tree_from_node() = delete;
102+
103+
public:
104+
using type = typical_segment_tree<T, MergeFunction>;
105+
};
93106
} // namespace mrpython
94107
#endif // MP_LIBRARY_SEGMENT_TREE_HPP

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "mp-oi-library",
33
"displayName": "mp-oi-library",
44
"description": "Some algorithms and data structures template for competitive programming.",
5-
"version": "0.2.1",
5+
"version": "0.2.2",
66
"repository": "https://github.com/Mr-Python-in-China/mp-oi-library",
77
"license": "LGPL-3.0-only",
88
"author": {

0 commit comments

Comments
 (0)