BOOL Bsc1::getMembersArray(IINST iinst, MBF mbf, OUT IINST **ppiinst, OUT ULONG *pciinst) { Array<IINST> rgIinst; EnumProps enm(this, iinst, &MODIDX::iuseMin, &BSC_PROP::iuse); while (enm.next()) { IPROP iprop = rgUse[enm.iCur].iprop + enm.ipropBase; IINST ii = iinstFrEn(rgProp[iprop].en); TYP typ = rgEn[ii].typ; if (typ != INST_TYP_MEMFUNC && typ != INST_TYP_MEMVAR) continue; if (!fInstFilter(ii, mbf)) continue; if (!ppiinst) { *pciinst = 1; return TRUE; } rgIinst.append(ii); } if (!DupArray(ppiinst, pciinst, rgIinst)) return FALSE; qsort(*ppiinst, *pciinst, sizeof(IINST), CmpIinst); return TRUE; }
void test_enumeration_hyperedges() { std::cout << "test_enumeration_hyperedges<Enum> with Enum = " <<typeid(Enum).name() << std::endl; { std::cout << "q = 0, r = 0" << std::endl; const int max_trivial_test = 10; for (int i = 0; i != max_trivial_test; ++i) { Enum enm(0,0,i); assert(enm.number_vertices_hypergraph == 1); assert(enm.size_hyperedges == 1); assert(enm.number_hyperedges == 1); assert(enm.current_hyperedge[0].empty()); } } { std::cout << "q = 1, r = 0" << std::endl; const int max_trivial_test = 10; for (int i = 1; i != max_trivial_test; ++i) { Enum enm(1,0,i); assert(enm.number_vertices_hypergraph == 1); assert(enm.size_hyperedges == 1); assert(enm.number_hyperedges == i); for (typename Enum::size_type j = 0; j != enm.number_hyperedges; ++j, enm.next()) { assert(enm.current_hyperedge.size() == 1); assert(enm.current_hyperedge[0].empty()); } } } { std::cout << "q = 1, r = 1" << std::endl; const int max_trivial_test = 10; for (int i = 1; i != max_trivial_test; ++i) { Enum enm(1,1,i); assert(enm.number_vertices_hypergraph == i); assert(enm.size_hyperedges == 1); assert(enm.number_hyperedges == i); for (typename Enum::size_type j = 0; j != enm.number_hyperedges; ++j, enm.next()) { assert(enm.current_hyperedge.size() == 1); assert(enm.current_hyperedge[0][0] == j); } } } }
BOOL Bsc1::getRefArray(IINST iinst, OUT IREF **ppiref, OUT ULONG *pciref) { Array<IREF> rgIref; EnumProps enm(this, iinst, &MODIDX::irefMin, &BSC_PROP::iref); while (enm.next()) { if (!ppiref) { *pciref = 1; return TRUE; } rgIref.append(enm.iCur); } return DupArray(ppiref, pciref, rgIref); }
BOOL Bsc1::getDervArray(IINST iinst, OUT IINST **ppiinst, OUT ULONG *pciinst) { Array<IINST> rgIinst; EnumProps enm(this, iinst, &MODIDX::ibaseMin, &BSC_PROP::iderv); while (enm.next()) { IPROP iprop = rgDerv[enm.iCur].iprop + enm.ipropBase; IINST ii = iinstFrEn(rgProp[iprop].en); if (!ppiinst) { *pciinst = 1; return TRUE; } rgIinst.append(ii); } return DupArray(ppiinst, pciinst, rgIinst); }
BOOL Bsc1::getUsesArray(IINST iinst, MBF mbf, OUT IINST **ppiinst, OUT ULONG *pciinst) { Array<IINST> rgIinst; EnumProps enm(this, iinst, &MODIDX::iuseMin, &BSC_PROP::iuse); while (enm.next()) { IPROP iprop = rgUse[enm.iCur].iprop + enm.ipropBase; IINST ii = iinstFrEn(rgProp[iprop].en); if (!fInstFilter(ii, mbf)) continue; if (!ppiinst) { *pciinst = 1; return TRUE; } rgIinst.append(ii); } return DupArray(ppiinst, pciinst, rgIinst); }