int main(){ Solution s; printList(s.partition(printList(buildList("")),3)); printList(s.partition(printList(buildList("1")),3)); printList(s.partition(printList(buildList("5")),3)); printList(s.partition(printList(buildList("1,4,3")),3)); printList(s.partition(printList(buildList("1,4,3,2,5,2")),3)); }
void XFE_FolderDropdown::syncFolderList() { MSG_Master *master = fe_getMNMaster(); int num_infos; if (m_infos) delete [] m_infos; /* this should be the number of MSG_FolderInfo's for mail, including servers. */ num_infos = MSG_GetFoldersWithFlag(master, MSG_FOLDER_FLAG_MAIL, NULL, 0); if (m_showNewsgroups) { num_infos += MSG_GetFoldersWithFlag(master, MSG_FOLDER_FLAG_NEWSGROUP, NULL, 0); m_numNewsHosts = MSG_GetFoldersWithFlag(master, MSG_FOLDER_FLAG_NEWS_HOST, NULL, 0); num_infos += m_numNewsHosts; } m_numinfos = num_infos; m_infos = new MSG_FolderInfo* [num_infos]; int pos = 0; /* build the default mail tree */ buildList(NULL, &pos); /* now we build each newshost */ if (m_numNewsHosts > 0) { MSG_FolderInfo **news_hosts; int i; news_hosts = new MSG_FolderInfo* [m_numNewsHosts]; MSG_GetFoldersWithFlag(master, MSG_FOLDER_FLAG_NEWS_HOST, news_hosts, m_numNewsHosts); for (i = 0; i < m_numNewsHosts; i++) buildList(news_hosts[i], &pos); delete [] news_hosts; } DD(printf("\nold m_numinfos = %d new numinfos %d\n", m_numinfos, pos);)
int main() { Solution s; vector<int> v1({6, 6, 6, 1, 2, 6, 6, 6, 3, 4, 5, 6, 6, 6}); ListNode *head = buildList(v1); printList(s.removeElements(head, 6)); printList(s.removeElements(nullptr, 6)); vector<int> v2({6, 6, 6}); ListNode *head2 = buildList(v2); printList(s.removeElements(head2, 6)); return 0; }
GLBitmap::GLBitmap( QGLWidget *parent, const QPoint & _origin, const Color & _color, const Brush & _width, const QPoint & _end ) : GLGraphicComponent( parent, _origin, _color, _width ), end( _end ) { Q_CHECK_PTR( parent ); setKindGraphic( GC_BITMAP ); id_graphic_component = glGenLists(1); buildList(); }
void ACLController::clicked(QAbstractButton *button) { if (button == m_add) { try { QHash<QString, VersionControl::User_var> hash; QStringList userList; VersionControl::UserAdminSeq *users = m_admin->getUsers(); for (unsigned int i = 0; i < users->length(); i++) { VersionControl::User_var user = (VersionControl::User_var)(*users)[i]; QString name = QString::fromUtf8(user->getName()); hash[name] = user; userList << name; } QString name = QInputDialog::getItem(m_d, "Assign user", "Select user:"******"Only administrators can assign users to a model.") } } else if (button == m_remove) {
bool ListBoxDnd::mouseMoveEvent( QMouseEvent * event ) { if ( event->state() & LeftButton ) { if ( ( event->pos() - mousePressPos ).manhattanLength() > 3 ) { ListBoxItemList list; buildList( list ); ListBoxItemDrag * dragobject = new ListBoxItemDrag( list, (dMode & Internal), (QListBox *) src ); // Emit signal for all dragged items QListBoxItem * i = list.first(); while ( i ) { emit dragged( i ); i = list.next(); } if ( dMode & Move ) { removeList( list ); // "hide" items } dragobject->dragCopy(); if ( dMode & Move ) { if ( dropConfirmed ) { // ###FIX: memleak ? in internal mode, only pointers are transfered... //list.setAutoDelete( TRUE ); list.clear(); dropConfirmed = FALSE; } insertList( list ); // "show" items } } } return FALSE; }
Playlist::Playlist( intf_thread_t *pIntf ): VarList( pIntf ) { // Get the playlist VLC object m_pPlaylist = pIntf->p_sys->p_playlist; buildList(); }
void VTableSpectrum::dump(FILE* output, const char* comment) { fprintf(output, "%s:\n", comment); Vector<KeyAndCount> list = buildList(); for (size_t index = list.size(); index-- > 0;) { KeyAndCount item = list.at(index); #if PLATFORM(MAC) Dl_info info; if (dladdr(item.key, &info)) { char* findResult = strrchr(info.dli_fname, '/'); const char* strippedFileName; if (findResult) strippedFileName = findResult + 1; else strippedFileName = info.dli_fname; fprintf(output, " %s:%s(%p): %lu\n", strippedFileName, info.dli_sname, item.key, item.count); continue; } #endif fprintf(output, " %p: %lu\n", item.key, item.count); } fflush(output); }
int main() { Solution s; vector<int> values({1, 2, 3, 4, 5}); ListNode *head = buildList(values); head->next->next->next->next = head->next; cout << s.detectCycle(head)->val << endl; return 0; }
void MediaList::refreshList() { if (createConnection()) { delete mediaList; mediaList = new QList<Media>; buildList(); closeConnection(); } }
//---------------------------------------------------------------------------- FreqSpheres::FreqSpheres(AudioEffect* effect, float strength, float strength2): Object3d(effect),st(strength),st2(strength2),freq(-1),t(0) { buildList(); quadratic = gluNewQuadric(); //gluQuadricNormals(quadratic, GLU_SMOOTH); //gluQuadricNormals(quadratic, GLU_FLAT); }
std::vector<CritterSpawnDef> SpawnDefinitions::getCritterSpawnDefinitions() { if(m_critter_spawn_list.size() < 1) { buildList(); } return m_critter_spawn_list; }
int main() { List* head, *end; buildList(head,end); for (int i = 0; i < 10; ++i) { appendList(head,end,2 * i); } List* p = lookupList(head, 6); }
void XFE_FolderDropdown::buildList(MSG_FolderInfo *info, int *position) { int num_children = MSG_GetFolderChildren(fe_getMNMaster(), info, NULL, 0); #ifdef DEBUG_dora // For debugging P0 bug on XP only. MSG_FolderLine line; printf("buildList %x\n", info); printf("num_children %d\n", num_children); if ( info ) { MSG_GetFolderLineById(fe_getMNMaster(), info, &line); if ( line.name) printf("folder name=%s\n", line.name); else printf("no folder name...\n"); } #endif if (num_children == 0) { return; } else { MSG_FolderInfo **tmp; int i; tmp = new MSG_FolderInfo* [num_children]; /* first we handle local mail stuff. */ MSG_GetFolderChildren(fe_getMNMaster(), info, tmp, num_children); for (i = 0; i < num_children; i ++) { if (*position >= m_numinfos) return; m_infos[*position] = tmp[i]; *position += 1; XP_ASSERT(tmp[i]); buildList(tmp[i], position); } delete [] tmp; } }
int main(int argc, char** argv) { switch(argc) { case 5: LIST_LEN = (1<<atoi(argv[4])); case 4: TOTAL_LISTS = (1<<atoi(argv[3])); case 3: REPEAT_TIMES = atoi(argv[2]); case 2: TOGETHER_NUM = atoi(argv[1]); break; default: break; } int syscpu = sysconf(_SC_NPROCESSORS_CONF); int processorid = 0; cpu_set_t mask; CPU_ZERO(&mask); CPU_SET(processorid, &mask); if (sched_setaffinity(0, sizeof(mask), &mask) == -1) { std::cerr << "could not set CPU affinity in main thread " << std::endl; } #ifdef USING_MALLOC head = (List**)malloc(TOTAL_LISTS*sizeof(List*)); allList = (List**)malloc(TOTAL_LISTS*sizeof(List*)); listsLen = (int*)malloc(TOTAL_LISTS*sizeof(int)); listNumber = (int*)malloc(TOTAL_LISTS*sizeof(int)); #else head = new List*[TOTAL_LISTS]; allList = new List*[TOTAL_LISTS]; listsLen = new int[TOTAL_LISTS]; listNumber = new int[TOTAL_LISTS]; #endif gettimeofday(&start, NULL); buildList(); gettimeofday(&end, NULL); double duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0; std::cerr << "build duration = " << duration << std::endl; gettimeofday(&start, NULL); int loopNum = TOTAL_LISTS/TOGETHER_NUM; if (TOTAL_LISTS%TOGETHER_NUM != 0) { loopNum++; } for (int i = 0; i < loopNum; i++) { tracingTask(i); } gettimeofday(&end, NULL); duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0; std::cout << "traverse duration " << duration << " s" << std::endl; std::cerr << "traverse duration " << duration << " s accum " << total_accum << " traverse " << tra_times << std::endl; destroyList(); return 0; }
/* ARTHUR 27/11 : Création sur base du travail de Paul */ MediaList::MediaList() { db = new QSqlDatabase(); mediaList = new QList<Media>(); if (createConnection()) { buildList(); closeConnection(); } else { qDebug() << "Error !" << endl; } }
void OrderDialog::setPageList(const QWidgetList &pages) { // The QWidget* are stored in a map indexed by the old index. // The old index is set as user data on the item instead of the QWidget* // because DnD is enabled which requires the user data to serializable m_orderMap.clear(); const int count = pages.count(); for (int i=0; i < count; ++i) m_orderMap.insert(i, pages.at(i)); buildList(); }
PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( wxWindow* aParent, BOARD* aBrd, LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask ) : PCB_LAYER_SELECTOR( aBrd ), DIALOG_LAYER_SELECTION_BASE( aParent ) { m_layerSelected = aDefaultLayer; m_notAllowedLayersMask = aNotAllowedLayersMask; buildList(); Layout(); GetSizer()->SetSizeHints( this ); SetFocus(); }
void MediaList::refreshList() { if(!db->isOpen()){ db->open(); } if (db->isOpen()) { delete mediaList; mediaList = new QList<Media>; buildList(); closeConnection(); } }
void VegetationWidget::slotImportTree() { QFileDialog* selectedFiles = new QFileDialog(this); selectedFiles->setFileMode(QFileDialog::ExistingFiles); selectedFiles->setLabelText(QFileDialog::FileName, QWidget::tr("文件")); selectedFiles->setLabelText(QFileDialog::FileType, QWidget::tr("文件")); selectedFiles->setLabelText(QFileDialog::Accept, QWidget::tr("确定")); selectedFiles->setLabelText(QFileDialog::Reject, QWidget::tr("取消")); QStringList fileNameFilters; fileNameFilters.push_back("files(*.osgb *.png *.tga)"); selectedFiles->setNameFilters(fileNameFilters); int retCode = selectedFiles->exec(); if (retCode) { std::string plantDir = g_SystemContext._workContextDir; plantDir.append(CONTEXT_DIR); plantDir.append("/Plant/"); QString treeDir = chineseTextUTF8ToQString(plantDir + "Tree/"); QStringList list = selectedFiles->selectedFiles(); bool findSameFileName = false; bool converSameFile = false; QList< QString > sameInListView; QList< QString > notSameInListView; for (int i = 0; i < list.size(); i++) { QFileInfo fileInfo(list[i]); QString fileName = fileInfo.fileName(); QString fileFullName = treeDir; fileFullName.append(fileName); if (QFile::exists(fileFullName)) { findSameFileName = true; sameInListView.push_back(fileName); } else notSameInListView.push_back(fileName); } if (findSameFileName) { QMessageBox messageBox(this); messageBox.setWindowTitle(QWidget::tr("提示")); messageBox.setIcon(QMessageBox::Question); messageBox.setText(QWidget::tr("发现同名的资源文件,是否覆盖?")); QPushButton *yesButton = messageBox.addButton(QWidget::tr("覆盖"), QMessageBox::YesRole); QPushButton *noButton = messageBox.addButton(QWidget::tr("跳过"), QMessageBox::NoRole); messageBox.exec(); if (messageBox.clickedButton() == yesButton) converSameFile = true; } copyFileToFolder(list, treeDir, converSameFile); buildList(); } }
void ACLController::itemChanged(QListWidgetItem *item) { if (item == NULL) return; const QString name = item->text(); try { m_model->changeUserLevel(m_hash[item].grantee, item->checkState() == Qt::Checked ? VersionControl::ReadWrite : VersionControl::Read); CATCH_DBERROR CATCH_INVALIDUSER CATCH_INVALIDMODEL } buildList(); }
int main(int argc, char** argv) { switch(argc) { case 5: LIST_LEN = (1<<atoi(argv[4])); case 4: TOTAL_LISTS = (1<<atoi(argv[3])); case 3: REPEAT_TIMES = atoi(argv[2]); case 2: CORO_NUM = atoi(argv[1]); break; default: break; } int syscpu = sysconf(_SC_NPROCESSORS_CONF); int quarterCore = syscpu/4; int bindid = quarterCore; //bindProc(bindid); bindProc(0); #ifdef USING_MALLOC head = (List**)malloc(TOTAL_LISTS*sizeof(List*)); allList = (List**)malloc(TOTAL_LISTS*sizeof(List*)); listsLen = (int*)malloc(TOTAL_LISTS*sizeof(int)); listNumber = (int*)malloc(TOTAL_LISTS*sizeof(int)); #else head = new List*[TOTAL_LISTS]; allList = new List*[TOTAL_LISTS]; listsLen = new int[TOTAL_LISTS]; listNumber = new int[TOTAL_LISTS]; #endif gettimeofday(&start, NULL); buildList(); gettimeofday(&end, NULL); double duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0; std::cerr << "build duration = " << duration << std::endl; //bindProc(0); AccirrInit(&argc, &argv); for (intptr_t i = 0; i < CORO_NUM; i++) { createTask(tracingTask, (void*)i); } gettimeofday(&start, NULL); AccirrRun(); AccirrFinalize(); gettimeofday(&end, NULL); duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0; std::cout << "traverse duration " << duration << " s accum " << total_accum << " traverse " << tra_times << std::endl; std::cerr << "traverse duration " << duration << " s accum " << total_accum << " traverse " << tra_times << std::endl; destroyList(); return 0; }
//---------------------------------------------------------------------------- Tree::Tree(AudioEffect* effect, int animMode, float armsSt):Object3d(effect),animate(animMode),aSt(armsSt) { buildList(); leftArm = rightArm = 0.0; boxScale = 1.0; redcolor = 1.0; chemin = 0; trigger = 0; counter = 0; }
void buildHistoryList() { HISTORY = linkedList(); FILE * fin = fopen(".mysh_history", "r"); if(fin != NULL) { int t = totalLinesInFile(fin); buildList(HISTORY, t, fin, buildHistory); fclose(fin); } trimList(); }
SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG( wxWindow* aParent, BOARD * aPcb, LAYER_ID aFrontLayer, LAYER_ID aBackLayer) : PCB_LAYER_SELECTOR( aPcb ), DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( aParent ) { m_frontLayer = aFrontLayer; m_backLayer = aBackLayer; m_leftRowSelected = 0; m_rightRowSelected = 0; buildList(); SetFocus(); GetSizer()->SetSizeHints( this ); Center(); }
//---------------------------------------------------------------------------- Tree::Tree(AudioEffect* effect):Object3d(effect) { buildList(); leftArm = rightArm = 0.0; boxScale = 1.0; redcolor = 1.0; animate = 0; chemin = 0; trigger = 0; counter = 0; aSt=1.0; }
CritterSpawnDef SpawnDefinitions::getSpawnGroup(const QString &spawn_group_name) { if(m_critter_spawn_list.size() < 1) { buildList(); } for(const auto &spawn_group : m_critter_spawn_list) { if(spawn_group.m_spawn_group.contains(spawn_group_name, Qt::CaseInsensitive)) return spawn_group; } qWarning() << "No matching \"" << spawn_group_name << "\" in g_defined_enemy_spawn_groups to sent group name." << "Returning ES_Contaminated_City_00_01 group as default..."; return m_critter_spawn_list[0]; }
void Model::render(RenderPass pass) { if (!_currentState || (pass > kRenderPassAll)) return; if (pass == kRenderPassAll) { Model::render(kRenderPassOpaque); Model::render(kRenderPassTransparent); return; } // Render buildList(pass); glCallList(_lists + pass); // Reset the first texture units TextureMan.reset(); }
/* Sets a custom texture */ bool Mouse::setTexture(const char *filename){ if(text) glDeleteTextures(1,&text); text = loadTexture(filename); if(!text){ logError("Couldn't load the texture for the cursor"); return false; } if(!list) buildList(); if(!list){ logError("Couldn't create the display list for the cursor"); return false; } return true; }
void AssignStmt::eval(std::map<std::string, Elt *> &name_table, std::map<std::string, Proc *> &function_table) const { // if we are evaluating the assignment of a list if (expression->eval(name_table, function_table)->isLst()) { std::cout << "list!" << std::endl; try { // call recursive buildList to handle dynamically allocating memory by building lists using the cons method Elt *L = buildList( ((Lst *)expression->eval(name_table, function_table)->getObject()), name_table, function_table ); // save the list to the name table name_table[name] = L; //std::map<std::string, Elt *>::iterator iter = name_table.begin(); //printf("BUILD LIST - String entry in name table using iter= %s\n", (*iter).first.c_str()); //int value = 0; //value = *(int*)(name_table.begin()->second->getValue(name_table, function_table)); //printf("BUILD LIST - Value read for first entry using iter= %d\n", (*iter).second->getValue(name_table, function_table)); } catch (...) { // we have run out of heap std::cout << "Error: out of heap" << std::endl; exit(0); } } // if we are evaluating the assignment of an integer, just store it to the name table else { std::cout << "int!" << std::endl; name_table[name] = expression->eval(name_table, function_table); } }