SUNphi  1.0
SUNphi::Vector< T > Class Template Reference

#include <Vector.hpp>

Inheritance diagram for SUNphi::Vector< T >:

Public Types

using Size = SignedOf< UnsignedSize >
 Signed version of the std::vector<T> size.
 

Public Member Functions

Size size () const
 Returns the signed size. More...
 
 Vector (const Vector &oth)
 Copy constructor.
 
template<typename Arg , typename... Args, TypeIf<(not isSame< const Vector &, Arg >), void * > = nullptr>
 Vector (Arg &&arg, Args &&...args)
 Forward constructor to std::vector.
 
 Vector ()
 Default constructor.
 
 Vector (std::initializer_list< T > il)
 Forward constrcution by initializing list.
 
summatorial (const UnsignedSize beg, const UnsignedSize end) const
 Computes the sum of all elements between [beg:end) More...
 
summatorial (const UnsignedSize beg=0) const
 
productorial (const UnsignedSize beg, const UnsignedSize end) const
 Computes the product of all elements between [beg:end) More...
 
productorial (const UnsignedSize beg=0) const
 
template<bool falseTrue, typename C , typename A >
Size loopUntil (const Size first, const Size last, C cond, A act) const
 Action to perform. More...
 
template<typename C >
Size findFirstWhereNot (C cond) const
 Finds the first element where the condition is false. More...
 
template<typename C >
Size findLastWhereNot (C cond) const
 Finds the last element where the condition is false. More...
 
Size findFirst (const T &val) const
 Finds the first element val. More...
 
Size findFirstDiffFrom (const T &val) const
 Finds the first element different from val. More...
 
Size findLast (const T &val) const
 Finds the last element val. More...
 
Size findLastDiffFrom (const T &val) const
 Finds the last element different from val. More...
 
bool isContained (const T &val) const
 Check if the value is contained.
 
auto scopePushBack (const T &val)
 Push back a value and pop it back when going out of scope.
 
std::string getStr () const
 Gets a string of form {1,2,3...}. More...
 
std::map< T, T > group () const
 
template<typename TOut >
void divWithMod (Vector< TOut > &quotient, Vector< TOut > &remainder, const Vector &divisor) const
 Returns the result and remainder of the division. More...
 

Static Public Member Functions

static auto getNullAction ()
 Null action.
 
static auto getTrueCondition ()
 True condition.
 
template<typename F >
static auto getActer (F f)
 Returns an operator acting on a given element.
 
template<bool Ret = true>
static auto getComparer (const T &val)
 Returns an operator comparing and returning Ret when occurring, !Ret if not. More...
 

Public Attributes

elements
 STL member.
 

Private Types

using UnsignedSize = typename std::vector< T >::size_type
 Type of the data returned by std::vector.
 

Detailed Description

template<typename T>
class SUNphi::Vector< T >

Class wrapping std::vector

Fix some some idiosinchrasy, such as the unsigned returned value of size, and adds some useful method

Definition at line 29 of file Vector.hpp.

Member Function Documentation

template<typename T>
template<typename TOut >
void SUNphi::Vector< T >::divWithMod ( Vector< TOut > &  quotient,
Vector< TOut > &  remainder,
const Vector< T > &  divisor 
) const
inline

Returns the result and remainder of the division.

Parameters
quotientResult of the division
remainderRemainder of the division
divisorDivisor to be used

Definition at line 310 of file Vector.hpp.

template<typename T>
Size SUNphi::Vector< T >::findFirst ( const T &  val) const
inline

Finds the first element val.

Parameters
valElement to find

Definition at line 214 of file Vector.hpp.

template<typename T>
Size SUNphi::Vector< T >::findFirstDiffFrom ( const T &  val) const
inline

Finds the first element different from val.

Parameters
valElement to find

Definition at line 222 of file Vector.hpp.

template<typename T>
template<typename C >
Size SUNphi::Vector< T >::findFirstWhereNot ( cond) const
inline

Finds the first element where the condition is false.

Parameters
condCondition to check

Definition at line 197 of file Vector.hpp.

template<typename T>
Size SUNphi::Vector< T >::findLast ( const T &  val) const
inline

Finds the last element val.

Parameters
valElement to find

Definition at line 230 of file Vector.hpp.

template<typename T>
Size SUNphi::Vector< T >::findLastDiffFrom ( const T &  val) const
inline

Finds the last element different from val.

Parameters
valElement to find

Definition at line 238 of file Vector.hpp.

template<typename T>
template<typename C >
Size SUNphi::Vector< T >::findLastWhereNot ( cond) const
inline

Finds the last element where the condition is false.

Parameters
condCondition to check

Definition at line 206 of file Vector.hpp.

template<typename T>
template<bool Ret = true>
static auto SUNphi::Vector< T >::getComparer ( const T &  val)
inlinestatic

Returns an operator comparing and returning Ret when occurring, !Ret if not.

Parameters
valValue to compare

Definition at line 148 of file Vector.hpp.

template<typename T>
std::string SUNphi::Vector< T >::getStr ( ) const
inline

Gets a string of form {1,2,3...}.

Generator of the string

Definition at line 263 of file Vector.hpp.

template<typename T>
std::map<T,T> SUNphi::Vector< T >::group ( ) const
inline

Group the vector returning a map

Example

Vector v({2,2,3});
v.group(); // {{2,2},{3,1}}

Result containing grouped factors

Definition at line 295 of file Vector.hpp.

template<typename T>
template<bool falseTrue, typename C , typename A >
Size SUNphi::Vector< T >::loopUntil ( const Size  first,
const Size  last,
cond,
act 
) const
inline

Action to perform.

Perform the action all elements starting from first up to last (excluded) or until the condition is true or false

Returns the last position where the condition was true, or the past-beyond delimiter if never occurred

Offset to move

Position

Parameters
firstFirst element to loop on
lastLast excluded element to loop on
condCondition function
actAction to perform

Definition at line 169 of file Vector.hpp.

template<typename T>
T SUNphi::Vector< T >::productorial ( const UnsignedSize  beg,
const UnsignedSize  end 
) const
inline

Computes the product of all elements between [beg:end)

Parameters
begBegin
endEnd

Definition at line 102 of file Vector.hpp.

template<typename T>
T SUNphi::Vector< T >::productorial ( const UnsignedSize  beg = 0) const
inline

Computes the product of all elements between [beg:end)

Case in which one only or no extreme is provided

Parameters
begBegin

Definition at line 113 of file Vector.hpp.

template<typename T>
Size SUNphi::Vector< T >::size ( ) const
inline

Returns the signed size.

Gets the unsigned size

Converts to sign

Definition at line 43 of file Vector.hpp.

template<typename T>
T SUNphi::Vector< T >::summatorial ( const UnsignedSize  beg,
const UnsignedSize  end 
) const
inline

Computes the sum of all elements between [beg:end)

Parameters
begBegin
endEnd

Definition at line 83 of file Vector.hpp.

template<typename T>
T SUNphi::Vector< T >::summatorial ( const UnsignedSize  beg = 0) const
inline

Computes the sum of all elements between [beg:end)

Case in which one only or no extreme is provided

Parameters
begBegin

Definition at line 94 of file Vector.hpp.


The documentation for this class was generated from the following file: