
#include "comb/setpart-rgs-lex.h"
#include "fxtiomanip.h"
//#include "sort/minmaxmed23.h"  // max2()
#include "fxttypes.h"

//#include "jjassert.h"


void
setpart_rgs_lex::print()  const
{
//    const char sep[]=", ";
    const char sep[]=" ";
    ulong n = n_;

    cout << "s[ ";
    for (ulong j=0; j<n; ++j)  cout << s_[j] << sep;
    cout << "]";

    cout << "    m[ ";
    for (ulong j=1; j<=n; ++j)  cout << m_[j] << sep;
    cout << "]";

//    jjassert( m_[0] == ~0UL );
}
// -------------------------


void
setpart_rgs_lex::print_set(ulong off/*=1*/)  const
{
    const ulong ns = m_[n_];  // number of sets
    for (ulong s=0; s<ns; ++s)
    {
        cout << "{";
        ulong u = 0;
        for (ulong k=0; k<n_; ++k)  u += (s_[k]==s );

        for (ulong k=0; k<n_; ++k)
        {
            if ( s_[k] == s )
            {
                cout << (k+off);
                if ( --u )  cout << ", ";
            }
        }
        cout << "}";
        if ( s+1<ns )  cout << ", ";
    }
}
// -------------------------

