VectorLess.h 1001 Bytes
Newer Older
Francois Gygi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2011 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
// VectorLess.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef VECTORLESS_H
#define VECTORLESS_H
21
#include <vector>
Francois Gygi committed
22 23 24 25 26 27

template <class T>
struct VectorLess
{
  // function object for indirect comparison of vector elements
  public:
28 29
  std::vector<T>& a_;
  VectorLess<T>(std::vector<T>& a) : a_(a) {};
Francois Gygi committed
30 31 32 33 34 35
  bool operator() (int i, int j) const
  {
    return a_[i] < a_[j];
  }
};
#endif