Skip to content

Commit ba74958

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

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

resource/planner/c++/mintime_resource_tree.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ bool mt_resource_rb_node_t::operator< (const mt_resource_rb_node_t &other) const
207207
return this->remaining < other.remaining;
208208
}
209209

210+
bool mt_resource_rb_node_t::operator== (const mt_resource_rb_node_t &other) const
211+
{
212+
return this->remaining == other.remaining;
213+
}
214+
215+
bool mt_resource_rb_node_t::operator!= (const mt_resource_rb_node_t &other) const
216+
{
217+
return !operator == (other);
218+
}
219+
220+
210221

211222
/*******************************************************************************
212223
* *

resource/planner/c++/mintime_resource_tree.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct mt_resource_rb_node_t
2424
int64_t subtree_min;
2525
int64_t remaining;
2626
bool operator< (const mt_resource_rb_node_t &other) const;
27+
bool operator== (const mt_resource_rb_node_t &other) const;
28+
bool operator!= (const mt_resource_rb_node_t &other) const;
2729
};
2830

2931
template <class mt_resource_rb_node_t, class NodeTraits>

0 commit comments

Comments
 (0)