SPH
Functions
ArrayUtils.h File Reference

Utilities to simplify working with arrays. More...

#include "math/MathUtils.h"
#include "objects/containers/ArrayView.h"
#include "objects/containers/Tuple.h"

Go to the source code of this file.

Functions

template<typename U , typename T , typename TFunctor , typename TComparator >
NAMESPACE_SPH_BEGIN Iterator< T > findByComparator (ArrayView< T > container, TFunctor &&functor, const U defaultValue, TComparator &&comparator)
 
template<typename U , typename T , typename TFunctor >
Iterator< T > findByMaximum (ArrayView< T > container, TFunctor &&functor)
 
template<typename U , typename T , typename TFunctor >
Iterator< T > findByMinimum (ArrayView< T > container, TFunctor &&functor)
 
template<typename U , typename T , typename TFunctor , typename TComparator >
Tuple< Iterator< T >, Iterator< T > > findPairByComparator (ArrayView< T > container, TFunctor &&functor, const U defaultValue, TComparator &&comparator)
 
template<typename U , typename T , typename TFunctor >
Tuple< Iterator< T >, Iterator< T > > findPairByMaximum (ArrayView< T > container, TFunctor &&functor)
 
template<typename U , typename T , typename TFunctor >
Tuple< Iterator< T >, Iterator< T > > findPairByMinimum (ArrayView< T > container, TFunctor &&functor)
 
template<typename TStorage , typename TFunctor >
int getCountMatching (const TStorage &container, TFunctor &&functor)
 
template<typename TStorage , typename TFunctor >
bool areAllMatching (const TStorage &container, TFunctor &&functor)
 
template<typename TStorage , typename TFunctor >
bool isAnyMatching (const TStorage &container, TFunctor &&functor)
 
template<typename TStorage >
bool areElementsUnique (const TStorage &container)
 
template<typename TStorage1 , typename TStorage2 >
bool haveCommonElements (const TStorage1 &c1, const TStorage2 &c2)
 Returns true if two containers have at least one element with the same value. More...
 

Detailed Description

Utilities to simplify working with arrays.

Author
Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
Date
2016-2021

Definition in file ArrayUtils.h.

Function Documentation

◆ areAllMatching()

template<typename TStorage , typename TFunctor >
bool areAllMatching ( const TStorage &  container,
TFunctor &&  functor 
)

Definition at line 103 of file ArrayUtils.h.

◆ areElementsUnique()

template<typename TStorage >
bool areElementsUnique ( const TStorage &  container)

Returns true if all elements stored in the container are unique, i.e. the container does not store any value more than once.

Definition at line 125 of file ArrayUtils.h.

◆ findByComparator()

template<typename U , typename T , typename TFunctor , typename TComparator >
NAMESPACE_SPH_BEGIN Iterator<T> findByComparator ( ArrayView< T >  container,
TFunctor &&  functor,
const U  defaultValue,
TComparator &&  comparator 
)

Definition at line 15 of file ArrayUtils.h.

◆ findByMaximum()

template<typename U , typename T , typename TFunctor >
Iterator<T> findByMaximum ( ArrayView< T >  container,
TFunctor &&  functor 
)

Definition at line 32 of file ArrayUtils.h.

◆ findByMinimum()

template<typename U , typename T , typename TFunctor >
Iterator<T> findByMinimum ( ArrayView< T >  container,
TFunctor &&  functor 
)

Definition at line 41 of file ArrayUtils.h.

◆ findPairByComparator()

template<typename U , typename T , typename TFunctor , typename TComparator >
Tuple<Iterator<T>, Iterator<T> > findPairByComparator ( ArrayView< T >  container,
TFunctor &&  functor,
const U  defaultValue,
TComparator &&  comparator 
)

Returns first the lower iterator

Todo:
ignore same iterator (inner = outer?) flag?

Definition at line 51 of file ArrayUtils.h.

◆ findPairByMaximum()

template<typename U , typename T , typename TFunctor >
Tuple<Iterator<T>, Iterator<T> > findPairByMaximum ( ArrayView< T >  container,
TFunctor &&  functor 
)

Definition at line 76 of file ArrayUtils.h.

◆ findPairByMinimum()

template<typename U , typename T , typename TFunctor >
Tuple<Iterator<T>, Iterator<T> > findPairByMinimum ( ArrayView< T >  container,
TFunctor &&  functor 
)

Definition at line 84 of file ArrayUtils.h.

◆ getCountMatching()

template<typename TStorage , typename TFunctor >
int getCountMatching ( const TStorage &  container,
TFunctor &&  functor 
)

Definition at line 92 of file ArrayUtils.h.

◆ haveCommonElements()

template<typename TStorage1 , typename TStorage2 >
bool haveCommonElements ( const TStorage1 &  c1,
const TStorage2 &  c2 
)

Returns true if two containers have at least one element with the same value.

Definition at line 139 of file ArrayUtils.h.

◆ isAnyMatching()

template<typename TStorage , typename TFunctor >
bool isAnyMatching ( const TStorage &  container,
TFunctor &&  functor 
)

Definition at line 113 of file ArrayUtils.h.