Skip to content

Commit e194dd5

Browse files
committed
planner: add == and != operators for scheduled_point_t
Problem: `scheduled_point_t` needs `==` and `!=` operators to simplify and improve equality testing for planner updates, assignment, and copy construction. Add the operators and the requisite .cpp file.
1 parent ba74958 commit e194dd5

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

resource/planner/c++/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ add_library(planner_cxx STATIC
33
./scheduled_point_tree.cpp
44
./mintime_resource_tree.cpp
55
./planner_multi.cpp
6+
./planner_internal_tree.cpp
67
./mintime_resource_tree.hpp
78
./planner_internal_tree.hpp
89
./scheduled_point_tree.hpp

resource/planner/c++/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ libplanner_cxx_la_SOURCES = \
3333
planner.cpp \
3434
planner_multi.cpp \
3535
scheduled_point_tree.cpp \
36-
mintime_resource_tree.cpp
36+
mintime_resource_tree.cpp \
37+
planner_internal_tree.cpp
3738

3839
libplanner_cxx_la_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/resource/planner/c++
3940

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*****************************************************************************\
2+
* Copyright 2024 Lawrence Livermore National Security, LLC
3+
* (c.f. AUTHORS, NOTICE.LLNS, LICENSE)
4+
*
5+
* This file is part of the Flux resource manager framework.
6+
* For details, see https://github.com/flux-framework.
7+
*
8+
* SPDX-License-Identifier: LGPL-3.0
9+
\*****************************************************************************/
10+
11+
extern "C" {
12+
#if HAVE_CONFIG_H
13+
#include "config.h"
14+
#endif
15+
}
16+
17+
#include "planner_internal_tree.hpp"
18+
19+
bool scheduled_point_t::operator== (const scheduled_point_t &o) const
20+
{
21+
if (point_rb != o.point_rb)
22+
return false;
23+
if (resource_rb != o.resource_rb)
24+
return false;
25+
if (at != o.at)
26+
return false;
27+
if (in_mt_resource_tree != o.in_mt_resource_tree)
28+
return false;
29+
if (new_point != o.new_point)
30+
return false;
31+
if (ref_count != o.ref_count)
32+
return false;
33+
if (remaining != o.remaining)
34+
return false;
35+
if (scheduled != o.scheduled)
36+
return false;
37+
38+
return true;
39+
}
40+
41+
bool scheduled_point_t::operator!= (const scheduled_point_t &o) const
42+
{
43+
return !operator == (o);
44+
}
45+
46+
47+
/*
48+
* vi: ts=4 sw=4 expandtab
49+
*/

resource/planner/c++/planner_internal_tree.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
* tree.
2020
*/
2121
struct scheduled_point_t {
22+
bool operator== (const scheduled_point_t &o) const;
23+
bool operator!= (const scheduled_point_t &o) const;
24+
2225
scheduled_point_rb_node_t point_rb; /* BST node for scheduled point tree */
2326
mt_resource_rb_node_t resource_rb; /* BST node for min-time resource tree */
2427
int64_t at; /* Resource-state changing time */

0 commit comments

Comments
 (0)