void GroupCalculator::calculateGroups(int classSize, int groupSize) { int numGroups = classSize / groupSize; results.resize(8); students.resize(classSize); for (int id = 0; id < classSize; ++id) students[id].insert(id); int assignmentId = 0; for (auto& result: results) { result.resize(numGroups); // Take each student, and try to put them in a group for (int student = 0; student < classSize; ++student) { // Go through the groups, to try and add this student for (int group = 0; group < numGroups; ++group) { // Skip full groups if ((int)result[group].size() >= groupSize) continue; // Check for conflicts (if the student worked with anyone in the group before) if (noConflicts(result[group], student)) { // Add the student to the group result[group].insert(student); // Add all of the group members to the student's set of partners students[student].insert(result[group].begin(), result[group].end()); break; // Would be better to make this a condition in the loop } // Otherwise try the next group } } ++assignmentId; } printResults(); }
void PluginFactory::load() { rescan(); for( PluginInfoList::iterator it = infoList.begin(); it != infoList.end(); ++it ) { PluginInfo *pluginInfo = (*it).first; QLibrary *lib = (*it).second; if ( !pluginInfo || !lib ) continue; PTRACE( 1, "\n '" << pluginInfo->name << "':\n" << "\tdescription:\t" << pluginInfo->description << "\n" << "\tauthor:\t\t" << pluginInfo->author ); Plugin::Type type = pluginInfo->type; int id = pluginInfo->id; Plugin *plugin = 0; if( onStartupMap.contains(id) ) { if( onStartupMap[id] == NotLoad ) continue; plugin = createPlugin( *it ); } else { if( ancaConf->readBoolEntry( LOAD_NEW_PLUGINS, LOAD_NEW_PLUGINS_DEFAULT ) && noConflicts(type) ) { onStartupMap[id] = Load; plugin = createPlugin( *it ); } else onStartupMap[id] = NotLoad; } // create GUI that plugin exports? if( pluginInfo->flags & P_HAS_GUI ) d->guiPlugins.append(plugin); } }
//---------------------------------------------------------------------------- Boolean Plcm::compactSide(compactType whichDir,int ccx,int ccy) // // Compacing in one direction. Returns true if required magnification coeficient // obtained. // { int actSize,savSize,otherSize,end; if(whichDir == HorizC) { otherSize=ccy; actSize=end=ccx; } else { otherSize=ccx; actSize=end=ccy; } int mid, pos1=0,npos1=0, pos2=end-1,npos2=end-1; savSize=actSize; mid=end/2; end--; for( ;pos1 < mid && pos2 >= mid;pos1++,pos2--,npos2--) { if (isEmpty(pos1,otherSize,whichDir) && (pos1==0 || noConflicts(pos1,otherSize,whichDir) ) ) { actSize--; deletePos(npos1,whichDir); npos2--; } else npos1++; if (isEmpty(pos2,otherSize,whichDir) && (pos2== end || noConflicts(pos2,otherSize,whichDir) ) ) { actSize--; deletePos(npos2,whichDir); } if (sizeOk(actSize,otherSize) ) // further compaction not required break; } if (savSize-actSize >0) if(whichDir==HorizC) { cout << "\n " << (savSize-actSize) << " column[s] deleted." << endl; layoutToBuild->bbx[HOR]=actSize*thisImage.size[HOR]+thisImage.overlap[HOR]; } else { cout << "\n " << (savSize-actSize) << " row[s] deleted." << endl; layoutToBuild->bbx[VER]=actSize*thisImage.size[VER]+thisImage.overlap[VER];; } return(sizeOk(actSize,otherSize)); }// Plcm::compactSide //