proconlib

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub anqooqie/proconlib

:heavy_check_mark: std::greater by second (tools/greater_by_second.hpp)

It compares two pairs by the second element.

Usage

std::vector<std::pair<int, int>> a;
std::sort(a.begin(), a.end(), tools::greater_by_second());

License

Author

Constructor

tools::greater_by_second comp();

It creates a comparator.

Constraints

Time Complexity

operator()

template <typename T1, typename T2>
bool comp(std::pair<T1, T2> x, std::pair<T1, T2> y);

It returns true if x.second > y.second. Otherwise, it returns false.

Constraints

Time Complexity

Required by

Verified with

Code

#ifndef TOOLS_GREATER_BY_SECOND_HPP
#define TOOLS_GREATER_BY_SECOND_HPP

#include <utility>

namespace tools {

  class greater_by_second {
  public:
    template <class T1, class T2>
    bool operator()(const ::std::pair<T1, T2>& x, const ::std::pair<T1, T2>& y) const {
      return x.second > y.second;
    }
  };
}

#endif
#line 1 "tools/greater_by_second.hpp"



#include <utility>

namespace tools {

  class greater_by_second {
  public:
    template <class T1, class T2>
    bool operator()(const ::std::pair<T1, T2>& x, const ::std::pair<T1, T2>& y) const {
      return x.second > y.second;
    }
  };
}


Back to top page