SUNphi
1.0
|
Implements a looper over all combinations of a given kind. More...
#include <Combinatorial.hpp>
Public Member Functions | |
bool | isSlotFree (const Slot &iSlot) const |
Check if the slot is free. | |
bool | isSlotFullyOccupied (const Slot &iSlot) const |
Check if the slot is fully occupied. | |
bool | canBeMovedRight (const Slot &iSlot) const |
Check if 1 object can be moved from the slot to the right one. | |
void | moveRight (const Slot &iSlot) |
Move right one element from the slot. | |
bool | canBeMovedLeft (const Slot &iSlot) const |
Check if 1 object can be moved from the slot to the left one. | |
void | moveLeft (const Slot &iSlot) |
Move left one element from the slot. | |
bool | advance () |
Go to next combo, returning true if was possible to do it. More... | |
bool | rewind () |
Go to previous combo, returning true if was possible to do it. More... | |
bool | rewindOrAdvance (const BACK_FORW &BackForw) |
Go backward or advance depending on the passed parameter. | |
const Vector< Int > & | operator() () const |
Const cast to the combinatorial. | |
template<typename... Ts> | |
decltype(auto) | operator() (Ts &&...ts) |
Vector< Int > | getFirst () const |
Get the firt combo. | |
void | setToFirst () |
Set to first combo. | |
void | setToLast () |
Set to last combo. | |
Vector< Int > | getLast () const |
Get the last combo. | |
Slot | nSlots () const |
Number of slots. | |
Int | nMaxObj () const |
Maximal number of objects that can be accommodated. | |
Combinatorial (const Vector< Int > &nMaxPerSlot, const int nObj, const bool lastOrFirst=false) | |
Constructor specifying the maximal number of objects per slot. More... | |
Static Public Member Functions | |
static bool | isPossibleToAccomodate (const Vector< Int > &nMaxPerSlot, const int nObj) |
Check if it is possible to combine the nObj into the slots. More... | |
Private Types | |
using | Slot = typename Vector< Int >::Size |
Type used to enumerate the slots. | |
Private Member Functions | |
Int | assignToSlots (Vector< Int > &res, Int nObjToAss, const Slot &firstSlot, const Slot &pastLastSlot, const Slot &dSlot) const |
Vector< Int > | getFirstOrLast (const FIRST_OR_LAST &firstLast) const |
Get the first or last combo. More... | |
Private Attributes | |
Vector< Int > | nMaxPerSlot |
Maximal number of objects per slot. | |
Int | nObj |
Number of objects. | |
Vector< Int > | nPerSlot |
Current combination. | |
Implements a looper over all combinations of a given kind.
Definition at line 21 of file Combinatorial.hpp.
|
inline |
Constructor specifying the maximal number of objects per slot.
nMaxPerSlot | Maximal number of objects per slot |
nObj | Number of objects |
lastOrFirst | Starts from first or last combo |
Definition at line 305 of file Combinatorial.hpp.
|
inline |
Go to next combo, returning true if was possible to do it.
Slot to move
Returned value
Number of object up to the slot
Definition at line 164 of file Combinatorial.hpp.
|
inlineprivate |
Assign n elements n the range, putting the maximum available in each of them
Returns the number of non-assigned elements
res | Result |
nObjToAss | Number of elements to assign |
firstSlot | First slot where to assign |
pastLastSlot | Slot before which to stop assigning |
dSlot | Offset between slots |
Definition at line 39 of file Combinatorial.hpp.
|
inlineprivate |
Get the first or last combo.
Returned value
Number of objects to assign
First slot to assign
Last slot to assign
Offset to move
Residual objects to assign
Definition at line 65 of file Combinatorial.hpp.
|
inlinestatic |
Check if it is possible to combine the nObj into the slots.
nMaxPerSlot | Maximal number of objects per slot |
nObj | Number of objects |
Definition at line 110 of file Combinatorial.hpp.
|
inline |
Overload the operator() const method
passing all args
ts | Arguments |
Definition at line 256 of file Combinatorial.hpp.
|
inline |
Go to previous combo, returning true if was possible to do it.
Slot to move
Returned value
Number of object before the slot
Definition at line 201 of file Combinatorial.hpp.