proconlib

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

View the Project on GitHub anqooqie/proconlib

:heavy_check_mark: std::greater by std::get (tools/greater_by_get.hpp)

It compares two values by std::get.

Usage

std::vector<std::tuple<int, int, int>> a;
std::sort(a.begin(), a.end(), tools::greater_by_get<2>());

License

Author

Constructor

template <std::size_t I>
tools::greater_by_get<I> comp();

It creates a comparator.

Constraints

Time Complexity

operator()

template <typename T>
bool comp.operator()(T x, T y);

It returns true if std::get<I>(x) > std::get<I>(y). Otherwise, it returns false.

Constraints

Time Complexity

Required by

Verified with

Code

#ifndef TOOLS_GREATER_BY_GET_HPP
#define TOOLS_GREATER_BY_GET_HPP

#include <cstddef>
#include <tuple>

namespace tools {

  template <::std::size_t I>
  struct greater_by_get {
    template <class T>
    bool operator()(const T& x, const T& y) const {
      return ::std::get<I>(x) > ::std::get<I>(y);
    }
  };
}

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



#include <cstddef>
#include <tuple>

namespace tools {

  template <::std::size_t I>
  struct greater_by_get {
    template <class T>
    bool operator()(const T& x, const T& y) const {
      return ::std::get<I>(x) > ::std::get<I>(y);
    }
  };
}


Back to top page