17#ifndef LIB_ALGORITHM_H_
18#define LIB_ALGORITHM_H_
24#define ROUNDUP(x, y) (((x) + (y) - 1) / (y))
26#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
31template <
class C,
class T>
32inline bool contains(C &c,
const T &val) {
33 return std::find(c.begin(), c.end(), val) != c.end();
36template <
class C,
class Pred>
37inline bool contains_if(C &c, Pred pred) {
38 return std::find_if(c.begin(), c.end(), pred) != c.end();
41template <
class C,
class Pred>
42inline void erase_if(C &c, Pred pred) {
43 for (
auto it = c.begin(); it != c.end();) {
51template <
class C,
class Pred>
52inline void remove_if(C &c, Pred pred) {
53 c.erase(std::remove_if(c.begin(), c.end(), pred), c.end());
56template <
class C,
class T>
57inline typename C::iterator find(C &c,
const T &val) {
58 return std::find(c.begin(), c.end(), val);
61using std::max_element;
62using std::min_element;
65inline typename C::const_iterator min_element(
const C &c) {
66 return min_element(c.begin(), c.end());
68template <
class C,
class Compare>
69inline typename C::const_iterator min_element(
const C &c, Compare comp) {
70 return min_element(c.begin(), c.end(), comp);
74inline typename C::const_iterator max_element(
const C &c) {
75 return max_element(c.begin(), c.end());
77template <
class C,
class Compare>
78inline typename C::const_iterator max_element(
const C &c, Compare comp) {
79 return max_element(c.begin(), c.end(), comp);
82template <
class Iter,
class Fn>
83inline Fn for_each(std::pair<Iter, Iter> range, Fn fn) {
84 return std::for_each(range.first, range.second, fn);
88Iter begin(std::pair<Iter, Iter> pr) {
92Iter end(std::pair<Iter, Iter> pr) {
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24