2015-07-20 21:01:13 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-07-20 21:01:13 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_BinaryPredicates_h
|
|
|
|
#define vtk_m_BinaryPredicates_h
|
|
|
|
|
2015-07-21 17:22:05 +00:00
|
|
|
#include <vtkm/internal/ExportMacros.h>
|
2015-07-20 21:01:13 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
2015-07-20 21:01:13 +00:00
|
|
|
|
|
|
|
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
2019-12-06 17:52:26 +00:00
|
|
|
/// returns True if and only if \c x is not equal to \c y.
|
|
|
|
/// @note: Requires that types T and U are comparable with !=.
|
|
|
|
struct NotEqual
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
VTKM_EXEC_CONT bool operator()(const T& x, const U& y) const
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
return x != y;
|
2015-07-20 21:01:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
2019-12-06 17:52:26 +00:00
|
|
|
/// returns True if and only if \c x is equal to \c y.
|
|
|
|
/// @note: Requires that types T and U are comparable with !=.
|
|
|
|
struct Equal
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
VTKM_EXEC_CONT bool operator()(const T& x, const U& y) const
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
return x == y;
|
2015-07-20 21:01:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
|
|
|
/// returns True if and only if \c x is less than \c y.
|
2019-12-06 17:52:26 +00:00
|
|
|
/// @note: Requires that types T and U are comparable with <.
|
2015-07-20 21:01:13 +00:00
|
|
|
struct SortLess
|
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
VTKM_EXEC_CONT bool operator()(const T& x, const U& y) const
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
|
|
|
return x < y;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
|
|
|
/// returns True if and only if \c x is greater than \c y.
|
2019-12-06 17:52:26 +00:00
|
|
|
/// @note: Requires that types T and U are comparable via operator<(U, T).
|
|
|
|
|
2015-07-20 21:01:13 +00:00
|
|
|
struct SortGreater
|
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
VTKM_EXEC_CONT bool operator()(const T& x, const U& y) const
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
|
|
|
return y < x;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
|
|
|
/// returns True if and only if \c x and \c y are True.
|
2019-12-06 17:52:26 +00:00
|
|
|
/// @note: Requires that types T and U are comparable with &&.
|
|
|
|
|
2015-07-20 21:01:13 +00:00
|
|
|
struct LogicalAnd
|
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
VTKM_EXEC_CONT bool operator()(const T& x, const U& y) const
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
|
|
|
return x && y;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
|
|
|
/// returns True if and only if \c x or \c y is True.
|
2019-12-06 17:52:26 +00:00
|
|
|
/// @note: Requires that types T and U are comparable with ||.
|
2015-07-20 21:01:13 +00:00
|
|
|
struct LogicalOr
|
|
|
|
{
|
2019-12-06 17:52:26 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
VTKM_EXEC_CONT bool operator()(const T& x, const U& y) const
|
2015-07-20 21:01:13 +00:00
|
|
|
{
|
|
|
|
return x || y;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace vtkm
|
|
|
|
|
2018-02-22 13:29:13 +00:00
|
|
|
#endif //vtk_m_BinaryPredicates_h
|