bool connectionValid(int mask, Stat S){ for (int i = 0; i < 5; i++) if (maskGet(mask, i)){ Stat::iterator it = SSfind(S, i); if (it != S.end()) S.erase(it); } return S.empty(); }
void SScombine(Stat &S, int i, int j){ Stat::iterator iti = SSfind(S, i); Stat::iterator itj = SSfind(S, j); if (iti == itj) return; set<int> s(*iti); for (set<int>::iterator it = itj->begin(); it != itj->end(); it++){ s.insert(*it); } S.erase(iti); S.erase(itj); S.insert(s); }
void SSinsert(Stat &S, int i, int j){ Stat::iterator it = SSfind(S, j); assert(it != S.end()); set<int> s(*it); S.erase(it); s.insert(i); S.insert(s); }