10#include <gtest/gtest.h>
23 static string msg =
"Hello";
29 int*
counter =
static_cast<int*
>(data);
58 string* msg =
static_cast<string*
>(result);
137 void* result =
table2.execute_event(0);
138 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
146 result =
table3.execute_event(0);
147 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
173 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
177 EXPECT_EQ(*
static_cast<int*
>(result), 42);
211 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
265 table.
register_event(0, [](
const string& s) {
return "Hello, " + s; });
316 std::function<
double(
double)> square = [](
double x) {
return x * x; };
317 std::function<
double(
double)>
cube = [](
double x) {
return x * x * x; };
345 table1.register_event(0, [](
int x) {
return x * 10; });
Dynamic (growable) event table implementation.
size_t size() const override
Get the current table size (implements Event_Table virtual method)
bool is_registered(const size_t index) const
Check if an event is registered at the given index.
void register_event(const size_t index, Callable &&fct)
Register an event at a specific index.
void unregister_event(const size_t index)
Unregister an event at the given index.
bool check(const size_t, F) const
Legacy check method (for backward compatibility).
auto execute_event(const size_t index, Args &&... args) const
Execute the event at the given index with type-safe arguments.
Fixed-size event table implementation.
size_t size() const override
Get table size (implements Event_Table virtual method)
Event-driven table abstraction for event-driven simulations.
void * event_echo(void *data)
void * event_hello(void *data)
void * event_increment(void *data)
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
std::string toupper(const char *str)
Convert a C std::string to upper-case.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.