public void iterateAllCombinations ( @ Nonnull final ICommonsList < DATATYPE > aElements , @ Nonnull final Consumer < ? super ICommonsList < DATATYPE > > aCallback ) { ValueEnforcer . notNull ( aElements , "Elements" ) ; ValueEnforcer . notNull ( aCallback , "Callback" ) ; for ( int nSlotCount = m_bAllowEmpty ? 0 : 1 ; nSlotCount <= m_nSlotCount ; nSlotCount ++ ) { if ( aElements . isEmpty ( ) ) { aCallback . accept ( new CommonsArrayList <> ( ) ) ; } else { // Add all permutations for the current slot count for ( final ICommonsList < DATATYPE > aPermutation : new CombinationGenerator <> ( aElements , nSlotCount ) ) aCallback . accept ( aPermutation ) ; } } }
Iterate all combination no matter they are unique or not .