chmax/chmin

romophic-library

使い方

chmax(a,b)a=max(a,b)の更新をする. 更新があった場合はtrueを返す. chminも同様:

実装

1
2
3
4
template <class T>
bool chmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template <class T>
bool chmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }

Depended on

Licensed under CC BY-NC-ND 4.0
All rights reserved.
Built with Hugo
Theme Stack is designed by Jimmy