bool HistoryView::getLaneParentsChilds(SCRef sha, int x, SList p, SList c) { ListViewDelegate* lvd = static_cast<ListViewDelegate*>(itemDelegate()); uint lane = x / lvd->laneWidth(); int t = getLaneType(sha, lane); if (t == EMPTY || t == -1) return false; // first find the parents p.clear(); QString root; if (!isFreeLane(t)) { p = git->revLookup(sha, fh)->parents(); // pointer cannot be NULL root = sha; } else { SCRef par(git->getLaneParent(sha, lane)); if (par.isEmpty()) { dbs("ASSERT getLaneParentsChilds: parent not found"); return false; } p.append(par); root = p.first(); } // then find children c = git->getChilds(root); return true; }
bool CheckIntersect( SList &slist1, SList &slist2) { SLNode *p1 = slist1.head(), *p2 = slist2.head(); if (!p1 || !p2) return false; SLNode* cross1 = CheckCircle(slist1); SLNode* cross2 = CheckCircle(slist2); // both has no circle if (!cross1 && !cross2) { // method1: check tails //while (p1->next) p1 = p1->next; //while (p2->next) p2 = p2->next; //return p1 == p2; //method2: connect list1 head and tail, check circle // circle cross point is intersect point slist1.tail()->next = slist1.head(); cross2 = CheckCircle(slist2); cout << "Intersect point " << cross2->val << endl; if (cross2) return true; } else if (cross1 && cross2){ // both has circle p1 = slist1.head(); bool pass = false; while (p1) { p1 = p1->next; if (p1 == cross2) return true; if (p1 == cross1) { if (pass) break; pass = true; } } } return false; }
void UpwardPlanRep::initMe() { m_Gamma.init(*this); isAugmented = false; FaceSinkGraph fsg(m_Gamma, s_hat); SList<face> extFaces; fsg.possibleExternalFaces(extFaces); OGDF_ASSERT(!extFaces.empty()); face f_ext = nullptr; for(face f : extFaces) { if (f_ext == nullptr) f_ext = f; else { if (f_ext->size() < f->size()) f_ext = f; } } m_Gamma.setExternalFace(f_ext); for(adjEntry adj : s_hat->adjEntries) { if (m_Gamma.rightFace(adj) == m_Gamma.externalFace()) { extFaceHandle = adj; break; } } computeSinkSwitches(); }
void test_pop_front(Test* test) { std::string s("hello"); SList* list =new SList("hello","world"); std::string act = list->pop_front(); test->equals(act,s); delete list; }
void Annotate::unify(SList dst, SCList src) { const QString m("Merge"); for (int i = 0; i < dst.size(); ++i) { if (dst.at(i) == m) dst[i] = src.at(i); } }
void test_push_front(Test* test) { std::string s("hello"); SList* list = new SList("hello","word"); list->push_front(s); std::string act=list->get_first()->get_stringi(); test->equals(act,s); delete list; }
void test_pop_back(Test* test) { std::string s("world"); SList* list = new SList("hello","world"); std::cout<<(*list)<<std::endl; std::string act = list->pop_back(); test->equals(act,s); delete list; }
void test_iter(Test* test) { SList* list = new SList("hello","wordl"); list->push_back("hi"); list->push_back("why"); for(SList_iterator it = list->begin();it!=list->end();it++) std::cout<<(*it).get_stringi()<<endl; delete list; }
void test_reverse(Test* test) { SList* list = new SList("hello","wordl"); list->push_back("hi"); list->push_back("why"); (*list).reverse(); delete list; }
void SList::reverse() { SList tmp; Elem *tmp_elem = front; while(tmp_elem) { tmp.push_front(tmp_elem->get_contents()); tmp_elem = tmp_elem->next; } tmp.swap(*this); }
int main() { SList ls; ls.Insert(8); ls.Insert(5); ls.Insert(4); ls.Insert(1); ls.Traversal(); ls.ReverseTraversal(); }
void FrontIsEmpty::run() { SList newList; try { string str = newList.front(); fail(); } catch (logic_error&) { pass(); } }
std::size_t Processer::StealHalf(Processer & other) { std::size_t runnable_task_count = runnable_list_.size(); SList<Task> tasks = runnable_list_.pop_back((runnable_task_count + 1) / 2); std::size_t c = tasks.size(); DebugPrint(dbg_scheduler, "proc[%u] steal proc[%u] work returns %d.", other.id_, id_, (int)c); if (!c) return 0; other.runnable_list_.push(std::move(tasks)); return c; }
void test_swap(Test* test) { SList *list = new SList("hello","world"); SList *list_ = new SList("hei","maailma"); list->swap((*list_)); std::cout<<(*list)<<std::endl; std::cout<<(*list_)<<std::endl; delete list; delete list_; }
int main(void){ SList<int> mylist; mylist.pushFront(10); mylist.pushFront(20); mylist.pushBack(30); for(auto it=mylist.begin();it!=mylist.end();++it){ cout << *it << endl; } return 0; }
SList *PCCTS_AST:: to_slist() { SList *list = new SList; PCCTS_AST *p; for (p=this; p!=NULL; p=p->right()) { list->add(p); } return list; }
void SwndContainerImpl::OnNextFrame() { if(!IsVisible(TRUE)) return; SList<ITimelineHandler*> lstCopy; CopyList(m_lstTimelineHandler,lstCopy); SPOSITION pos=lstCopy.GetHeadPosition(); while(pos) { ITimelineHandler * pHandler=lstCopy.GetNext(pos); pHandler->OnNextFrame(); } }
bool CommitImpl::getFiles(SList selFiles) { // check for files to commit selFiles.clear(); QTreeWidgetItemIterator it(treeWidgetFiles); while (*it) { if ((*it)->checkState(0) == Qt::Checked) selFiles.append((*it)->text(0)); ++it; } return !selFiles.isEmpty(); }
void test7() { SList list; list.PushBack(1); list.PushBack(2); list.PushBack(3); list.PushBack(4); list.PushBack(5); list.PushBack(6); list.Circle(); cout << (list.CheckCycle())->_data << endl; cout << (list.GetCycleEntryNode(list.CheckCycle()))->_data << endl; cout << (list.GetCircleLength(list.CheckCycle())) << endl; }
int main() { SList sList; sList.PrintList(); int count = 10; while(count--) { AddElement(sList); } std::cout << "insert a elelment at pos 8" << std::endl; Node pos(8); Node node(101); sList.InsertElement(&node, &pos); sList.PrintList(); std::cout << std::endl << "The Size : " << sList.GetListSize() << std::endl; std::cout << std::endl; std::cout << "delete a element node 8" << std::endl; Node del(8); sList.DeleteElement(&node); sList.PrintList(); std::cout << std::endl << "The Size : " << sList.GetListSize() << std::endl; return 0; }
void AddElement(SList& slist) { static int value = 0; Node node(value++); slist.AddElement(&node); }
int main() { SList<int>* list = new SList<int>; list->insertHead(54); SLNode<string> node1; node1.setContents("23"); string x = node1.getContents(); SLNode<string> node2("hello"); node2.setNextNode(&node1); SLNode<string>* tmp = node2.getNextNode(); return 0; }
void Git::userInfo(SList info) { /* git looks for commit user information in following order: - GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables - repository config file - global config file - your name, hostname and domain */ const QString env(QProcess::systemEnvironment().join(",")); QString user(env.section("GIT_AUTHOR_NAME", 1).section(",", 0, 0).section("=", 1).trimmed()); QString email(env.section("GIT_AUTHOR_EMAIL", 1).section(",", 0, 0).section("=", 1).trimmed()); info.clear(); info << "Environment" << user << email; errorReportingEnabled = false; // 'git config' could fail, see docs run("git config user.name", &user); run("git config user.email", &email); info << "Local config" << user << email; run("git config --global user.name", &user); run("git config --global user.email", &email); info << "Global config" << user << email; errorReportingEnabled = true; }
node FaceSinkGraph::dfsStAugmentation( node v, // current node node parent, // its parent Graph &G, // original graph (not const) SList<edge> &augmentedEdges) // list of augmented edges { bool isFace = (m_originalFace[v] != nullptr); node vf = (parent != nullptr) ? m_originalNode[parent] : nullptr; // since we already know that T is a tree we can omit the visited array for(adjEntry adj : v->adjEntries) { node w = adj->twinNode(); if (w == parent) continue; if (isFace) { if (vf == nullptr) { vf = G.newNode(); } edge ew = G.newEdge(m_originalNode[w],vf); augmentedEdges.pushBack(ew); } dfsStAugmentation(w,v,G,augmentedEdges); } return vf; }
int main() { SList<int> sl; sl.insert_last(1); //sl.insert_last(2); //sl.insert_last(3); //sl.insert_last(4); //sl.insert_last(5); sl.display(); overturn_slist(sl); //overturn_slist_recur(sl.head, sl); sl.display(); return 0; }
STATUS UserManager::RowDeletedEventHandler( void *pRow, U32 rowCount, ShadowTable* ){ SList container; if( m_isIniting ){ m_shouldReinit = true; return OK; } User *pUser = new User( GetListenManager() ); pUser->BuildYourselfFromPtsRow( (UserAccessTableEntry *)pRow ); container.Add( (CONTAINER_ELEMENT)pUser ); DeleteObjectsFromTheSystem( container ); SetIsReadyToServiceRequests( true ); return OK; }
void UpwardPlanRep::removeSinkArcs(SList<adjEntry> &crossedEdges) { if (crossedEdges.size() == 2) return; SListIterator<adjEntry> itPred = crossedEdges.begin(), it; for(it = itPred.succ(); it.valid() && it.succ().valid(); ++it) { adjEntry adj = *it; if (m_isSinkArc[adj->theEdge()]) { m_Gamma.joinFaces(adj->theEdge()); crossedEdges.delSucc(itPred); it = itPred; continue; } itPred = it; } m_Gamma.setExternalFace(m_Gamma.rightFace(extFaceHandle)); }
int main() { int a = 45; int b = 23; cout << "before a:"<< a << "; b:" << b<<endl; swapInt(a,b); cout << "after a:"<< a << "; b:" << b<<endl; int *pData =new int[10]; for(int i=0; i< 10; i++) pData[i]= i+1; SwapObject aObj; aObj.SetData(10,pData); delete[] pData; int *pSwap =new int[20]; for(int i=0; i< 20; i++) pSwap[i]= 10+i+1; SwapObject bObj; bObj.SetData(20,pSwap); delete[] pSwap; cout << "before a:"<< aObj.Print() << "\nb:" << bObj.Print()<<endl; SwapObject::SwapContent(aObj,bObj); cout << "before a:"<< aObj.Print() << "\nb:" << bObj.Print()<<endl; SList *pTestList = new SList(); pTestList->InitSList(5); pTestList->ReleaseSList(); delete pTestList; return 0; }
// // createSkeleton: creates a skeleton graph // DynamicSkeleton& DynamicSPQRTree::createSkeleton(node vT) const { DynamicSkeleton& S = *OGDF_NEW DynamicSkeleton(this, vT); SList<node> inMapV; for (edge eH : m_tNode_hEdges[vT]) { node sH = eH->source(); node tH = eH->target(); edge& eM = m_skelEdge[eH]; node& sM = m_mapV[sH]; node& tM = m_mapV[tH]; if (!sM) { sM = S.m_M.newNode(); S.m_origNode[sM] = sH; inMapV.pushBack(sH); } if (!tM) { tM = S.m_M.newNode(); S.m_origNode[tM] = tH; inMapV.pushBack(tH); } eM = S.m_M.newEdge(sM, tM); S.m_origEdge[eM] = eH; } while (!inMapV.empty()) m_mapV[inMapV.popFrontRet()] = nullptr; S.m_referenceEdge = m_tNode_hRefEdge[vT]; if (S.m_referenceEdge) S.m_referenceEdge = m_skelEdge[S.m_referenceEdge]; m_sk[vT] = &S; return S; }
void StorageElementArray::ReportYourUnderlyingDevices( Container &devices ){ SList tempContainer; StorageElement *pElement; U32 index; DesignatorId *pId; devices.RemoveAll(); for( index = 0 ; index < GetChildCount(); index++ ){ // request a list for every child pElement = (StorageElement *)GetChild( index ); pElement->ReportYourUnderlyingDevices( tempContainer ); // move ids into the main vector while( tempContainer.Count() ){ tempContainer.GetAt( (CONTAINER_ELEMENT &)pId, 0 ); tempContainer.RemoveAt( 0 ); devices.Add( (CONTAINER_ELEMENT) pId ); } } }