Skip to content

Commit 1229af0

Browse files
committed
scheduled_point_rb_node_t: add ==, != operators
Problem: `scheduled_point_rb_node_t` needs `==` and `!=` operators to simplify and improve equality testing for planner updates, assignment, and copy construction. Add the operators.
1 parent cd2fb0f commit 1229af0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

resource/planner/c++/scheduled_point_tree.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ bool operator<(const int64_t lhs, const scheduled_point_rb_node_t &rhs) {
6464
return lhs < rhs.get_point ()->at;
6565
}
6666

67+
bool scheduled_point_rb_node_t::operator== (
68+
const scheduled_point_rb_node_t &other) const
69+
{
70+
return this->get_point ()->at == other.get_point ()->at;
71+
}
72+
73+
bool scheduled_point_rb_node_t::operator!= (
74+
const scheduled_point_rb_node_t &other) const
75+
{
76+
return !operator == (other);
77+
}
78+
6779

6880
/*******************************************************************************
6981
* *

resource/planner/c++/scheduled_point_tree.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ struct scheduled_point_rb_node_t
4343
: public rb_node_base_t,
4444
public ygg::RBTreeNodeBase<scheduled_point_rb_node_t> {
4545
bool operator< (const scheduled_point_rb_node_t &other) const;
46+
bool operator== (const scheduled_point_rb_node_t &other) const;
47+
bool operator!= (const scheduled_point_rb_node_t &other) const;
4648
};
4749

4850
using scheduled_point_rb_tree_t = ygg::RBTree<scheduled_point_rb_node_t,

0 commit comments

Comments
 (0)