mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
integrating the existing state of TON Storage / TON Payments / CPS Fift development branches
This commit is contained in:
parent
040df63c98
commit
4e2624459b
153 changed files with 10760 additions and 1695 deletions
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/optional.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
@ -80,4 +81,27 @@ class TimedStat {
|
|||
}
|
||||
};
|
||||
|
||||
template <class T, class Cmp>
|
||||
struct MinMaxStat {
|
||||
public:
|
||||
using Event = T;
|
||||
void on_event(Event event) {
|
||||
if (!best_ || Cmp()(event, best_.value())) {
|
||||
best_ = event;
|
||||
}
|
||||
}
|
||||
td::optional<T> get_stat() const {
|
||||
return best_.copy();
|
||||
}
|
||||
|
||||
private:
|
||||
td::optional<T> best_;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
using MinStat = MinMaxStat<T, std::less<>>;
|
||||
|
||||
template <class T>
|
||||
using MaxStat = MinMaxStat<T, std::greater<>>;
|
||||
|
||||
} // namespace td
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue