TimonKnigge / TCR

Team Code Reference for programming contests
24 stars 5 forks source link

increasing_function should overwrite on insert #8

Open RagnarGrootKoerkamp opened 5 years ago

RagnarGrootKoerkamp commented 5 years ago

std::insert doesn't overwrite, while we need this to update an existing index to a better value. Just using m[x] works, but is much slower.

https://github.com/TimonKnigge/TCR/blob/master/snippets/datastructures/increasing_function.cpp#L12

TimonKnigge commented 5 years ago

Are you really that worried about the performance of m[x] = y? I'm also a bit uncomfortable with this hint parameter by the way, since apparently it behaves differently until C++11 then in C++11 and later [1].

[1] https://en.cppreference.com/w/cpp/container/set/insert