14 template <
typename U,
typename T,
typename TFunctor,
typename TComparator>
18 TComparator&& comparator) {
19 U maxValue = defaultValue;
22 U value = functor(*iter);
23 if (comparator(value, maxValue)) {
31 template <
typename U,
typename T,
typename TFunctor>
33 return findByComparator<U>(
34 container, std::forward<TFunctor>(functor), U(-
INFTY), [](
const U& v1,
const U& v2) {
40 template <
typename U,
typename T,
typename TFunctor>
42 return findByComparator<U>(
43 container, std::forward<TFunctor>(functor), U(
INFTY), [](
const U& v1,
const U& v2) {
50 template <
typename U,
typename T,
typename TFunctor,
typename TComparator>
54 TComparator&& comparator) {
57 U maxValue = defaultValue;
58 for (
Iterator<T> outerIter = container.
begin(); outerIter != container.
end(); ++outerIter) {
59 for (
Iterator<T> innerIter = container.
begin(); innerIter != container.
end(); ++innerIter) {
60 if (outerIter == innerIter) {
63 U value = functor(*innerIter, *outerIter);
64 if (comparator(value, maxValue)) {
65 maxOuterIter = outerIter;
66 maxInnerIter = innerIter;
71 return maxInnerIter > maxOuterIter ?
makeTuple(maxOuterIter, maxInnerIter)
75 template <
typename U,
typename T,
typename TFunctor>
77 return findPairByComparator<U>(
78 container, std::forward<TFunctor>(functor), U(-
INFTY), [](
const U& v1,
const U& v2) {
83 template <
typename U,
typename T,
typename TFunctor>
85 return findPairByComparator<U>(
86 container, std::forward<TFunctor>(functor), U(
INFTY), [](
const U& v1,
const U& v2) {
91 template <
typename TStorage,
typename TFunctor>
94 for (
const auto& t : container) {
102 template <
typename TStorage,
typename TFunctor>
104 for (
const auto& t : container) {
112 template <
typename TStorage,
typename TFunctor>
114 for (
const auto& t : container) {
124 template <
typename TStorage>
127 for (
auto iter1 = container.begin(); iter1 != container.end(); ++iter1) {
128 for (
auto iter2 = iter1; iter2 != container.end(); ++iter2) {
129 if (*iter2 == *iter1 && iter2 != iter1) {
138 template <
typename TStorage1,
typename TStorage2>
140 for (
const auto& t1 : c1) {
141 for (
const auto& t2 : c2) {
bool areElementsUnique(const TStorage &container)
bool haveCommonElements(const TStorage1 &c1, const TStorage2 &c2)
Returns true if two containers have at least one element with the same value.
Iterator< T > findByMaximum(ArrayView< T > container, TFunctor &&functor)
Tuple< Iterator< T >, Iterator< T > > findPairByComparator(ArrayView< T > container, TFunctor &&functor, const U defaultValue, TComparator &&comparator)
Tuple< Iterator< T >, Iterator< T > > findPairByMaximum(ArrayView< T > container, TFunctor &&functor)
NAMESPACE_SPH_BEGIN Iterator< T > findByComparator(ArrayView< T > container, TFunctor &&functor, const U defaultValue, TComparator &&comparator)
int getCountMatching(const TStorage &container, TFunctor &&functor)
Tuple< Iterator< T >, Iterator< T > > findPairByMinimum(ArrayView< T > container, TFunctor &&functor)
bool isAnyMatching(const TStorage &container, TFunctor &&functor)
bool areAllMatching(const TStorage &container, TFunctor &&functor)
Iterator< T > findByMinimum(ArrayView< T > container, TFunctor &&functor)
Simple non-owning view of a container.
Additional math routines (with more includes).
#define NAMESPACE_SPH_END
Re-implementation of std::tuple with some additional functionality.
INLINE auto makeTuple(TArgs &&... args)
Creates a tuple from a pack of values, utilizing type deduction.
Object providing safe access to continuous memory of data.
INLINE Iterator< StorageType > begin()
INLINE Iterator< StorageType > end()
Simple (forward) iterator over continuous array of objects of type T.
Heterogeneous container capable of storing a fixed number of values.