use list instead of map to keep order

This commit is contained in:
Joachim Schoeberl 2024-01-18 19:43:08 +01:00
parent 5a4b89c1ed
commit eb90c6ed3b

View File

@ -51,19 +51,22 @@ namespace ngcore
class SimpleSignal class SimpleSignal
{ {
private: private:
std::map<void*,std::function<void()>> funcs; // std::map<void*,std::function<void()>> funcs;
std::list<std::pair<void*,std::function<void()>>> funcs;
public: public:
SimpleSignal() = default; SimpleSignal() = default;
template<typename FUNC> template<typename FUNC>
void Connect(void* var, FUNC f) void Connect(void* var, FUNC f)
{ {
funcs[var] = f; // funcs[var] = f;
funcs.push_back ( { var, f } );
} }
void Remove(void* var) void Remove(void* var)
{ {
funcs.erase(var); // funcs.erase(var);
funcs.remove_if([&] (auto var_f) { return var_f.first==var; });
} }
inline void Emit() inline void Emit()