예제 #1
0
static list<int> listElements(const DisjointSets &ds, int set)
{
    list<int> elements;
    for (int i = 0; i < ds.NumElements(); ++i)
    {
        if (ds.FindSet(i) == ds.FindSet(set))
            elements.push_front(i);
    }
    return elements;
}
예제 #2
0
static list<int> listSets(const DisjointSets &ds)
{
    list<int> sets;
    for (int i = 0; i < ds.NumElements(); ++i)
    {
        if (ds.FindSet(i) == i)
            sets.push_front(i);
    }
    return sets;
}
예제 #3
0
void printElementSets(const DisjointSets & s)
{
	for (int i = 0; i < s.NumElements(); ++i)
		cout << s.FindSet(i) << "  ";
	cout << endl;
}