本文整理汇总了C++中SList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::begin方法的具体用法?C++ SList::begin怎么用?C++ SList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void VarEdgeInserterDynUMLCore::BCandSPQRtreesUML::insertEdgePath(
edge eOrig, const SList<adjEntry>& crossedEdges)
{
SList<edge> ti;
SList<node> tj;
for (adjEntry adj : crossedEdges) {
ti.pushBack(adj->theEdge());
tj.pushBack(adj->theEdge()->target());
}
m_pr.insertEdgePath(eOrig, crossedEdges);
Graph::EdgeType typeOfEOrig = m_pr.typeOrig(eOrig);
int costOfEOrig = m_costOrig ? eOrig ? (*m_costOrig)[eOrig] : 0 : 1;
node v = m_pr.copy(eOrig->source());
SListConstIterator<edge> it = ti.begin();
SListConstIterator<node> jt = tj.begin();
SListConstIterator<adjEntry> kt;
for (kt = crossedEdges.begin(); it.valid(); ++it, ++jt, ++kt) {
edge e = *it;
node u = e->target();
adjEntry a;
for (a = u->firstAdj(); a->theEdge()->target() != *jt; a = a->succ())
;
edge f = a->theEdge();
m_dynamicSPQRForest.updateInsertedNode(e, f);
e = m_dynamicSPQRForest.rep(e);
f = m_dynamicSPQRForest.rep(f);
m_typeOf[f] = m_typeOf[e];
m_cost[f] = m_cost[e];
for (a = u->firstAdj(); a->theEdge()->source() != v; a = a->succ());
f = a->theEdge();
m_dynamicSPQRForest.updateInsertedEdge(f);
f = m_dynamicSPQRForest.rep(f);
m_typeOf[f] = typeOfEOrig;
m_cost[f] = costOfEOrig;
v = u;
}
node u = m_pr.copy(eOrig->target());
adjEntry a;
for (a = v->firstAdj(); a->theEdge()->target() != u; a = a->succ())
;
edge f = a->theEdge();
m_dynamicSPQRForest.updateInsertedEdge(f);
f = m_dynamicSPQRForest.rep(f);
m_typeOf[f] = typeOfEOrig;
m_cost[f] = costOfEOrig;
}
示例2: test_iter
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;
}
示例3: testSList
void testSList()
{
SList list;
list.push_front("Alice");
list.push_front("Bob");
list.push_front("Copernicus");
for (SList::ConstIterator cit = list.begin(); cit != list.end(); ++cit) {
std::cout << *cit << std::endl;
}
std::cout << std::endl;
for (SList::Iterator it = list.begin(); it != list.end(); ++it) {
std::cout << *it << std::endl;
}
std::cout << std::endl;
}
示例4: main
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;
}
示例5: main
int main()
{
SList<int> intList;
POSITION p1=intList.push_back(1);
POSITION p2=intList.push_back(2);
POSITION p3=intList.push_back(3);
POSITION p4=intList.push_back(4);
POSITION p5=intList.push_back(5);
for(POSITION p=intList.start(); p != 0 ;p=intList.next(p)) //A != operátort end()-re nem tudta értelmezni így helyette 0-t írtam
{
cout<<intList.getAt(p)<<endl;
}
cout<<"Remove: "<<intList.remove(p2)<<endl;
cout<<"Remove: "<<intList.remove(p1)<<endl;
cout<<"Remove: "<<intList.remove(p5)<<endl;
cout<<"Remove: "<<intList.remove(p3)<<endl;
intList.insert_after(p4,10);
intList.insert_after(p4,11);
for(POSITION p2=intList.start();p2 != 0; p2= intList.next(p2)) //A != operátort end()-re nem tudta értelmezni így helyette 0-t írtam
{
cout<<intList.getAt(p2)<<endl;
}
cout << "iteratorral:\n";
for(SList<int>::iterator it = intList.begin(); it != intList.end(); ++it)
cout << *it << " ";
cout << endl;
SList<int> intList_2 = intList.reverse(); //A reverse függvény értelmetlen lenne másoló kontruktor használata nélkül
//A konstokat pedig iterátor használat céljából távolítottuk el.
cout << "A forditott lista: ";
for(SList<int>::iterator it = intList_2.begin(); it != intList_2.end(); ++it)
cout << *it << " ";
cout << endl;
SList<int> intList_3 = intList.concatenate(intList_2); //A concatenate tesztelése
cout << "Az eredeti es a forditott lista osszefuzese: ";
for(SList<int>::iterator it = intList_3.begin(); it != intList_3.end(); ++it)
cout << *it << " ";
cout << endl;
getchar();
return 0;
}
示例6: main
int main(void){
SList<int> list;
SList<int>::iterator i;
list.insert(5);
list.insert(6);
list.insert(1);
list.insert(2);
// list.append(10);
// list.rmFirst();
// list.rmLast();
for(i=list.begin();i!=list.end();i++){
cout << *i << endl;
}
for(i=list.begin();i!=list.end();i++){
*i = *i + 1;
}
for(i=list.begin();i!=list.end();i++){
cout << *i << endl;
}
}
示例7: removeSinkArcs
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));
}
示例8: checkAcyclic
// test if graphAcyclicTest plus edges in tmpAugmented is acyclic
// removes added edges again
bool UpwardPlanarSubgraphSimple::checkAcyclic(
GraphCopySimple &graphAcyclicTest,
SList<Tuple2<node,node> > &tmpAugmented)
{
SListPure<edge> added;
SListConstIterator<Tuple2<node,node> > it;
for(it = tmpAugmented.begin(); it.valid(); ++it)
added.pushBack(graphAcyclicTest.newEdge(
graphAcyclicTest.copy((*it).x1()),
graphAcyclicTest.copy((*it).x2())));
bool acyclic = isAcyclic(graphAcyclicTest);
SListConstIterator<edge> itE;
for(itE = added.begin(); itE.valid(); ++itE)
graphAcyclicTest.delEdge(*itE);
return acyclic;
}
示例9:
void PlanarSubgraphPQTree::
removeEliminatedLeaves(SList<PQLeafKey<edge,whaInfo*,bool>*> &eliminatedKeys)
{
PQNode<edge,whaInfo*,bool>* nodePtr = 0;
PQNode<edge,whaInfo*,bool>* parent = 0;
PQNode<edge,whaInfo*,bool>* sibling = 0;
SListIterator<PQLeafKey<edge,whaInfo*,bool>*> it;
for (it = eliminatedKeys.begin(); it.valid(); it++)
{
nodePtr = (*it)->nodePointer();
parent = nodePtr->parent();
sibling = nodePtr->getNextSib(NULL);
removeNodeFromTree(parent,nodePtr);
checkIfOnlyChild(sibling,parent);
if (parent->status() == TO_BE_DELETED)
{
parent->status(WHA_DELETE);
}
nodePtr->status(WHA_DELETE);
}
}
示例10: insertEdge
void FixEdgeInserterCore::insertEdge(CombinatorialEmbedding &E, edge eOrig, const SList<adjEntry> &crossed)
{
// remove dual nodes on insertion path
SListConstIterator<adjEntry> it;
for(it = crossed.begin(); it != crossed.rbegin(); ++it) {
m_dual.delNode(m_nodeOf[E.rightFace(*it)]);
}
// update primal
m_pr.insertEdgePathEmbedded(eOrig,E,crossed);
// insert new face nodes into dual
const List<edge> &path = m_pr.chain(eOrig);
for(edge e : path)
{
adjEntry adj = e->adjSource();
m_nodeOf[E.leftFace (adj)] = m_dual.newNode();
m_nodeOf[E.rightFace(adj)] = m_dual.newNode();
}
// insert new edges into dual
for(edge e : path)
insertEdgesIntoDual(E, e->adjSource());
}
示例11: call
void UpwardPlanarSubgraphSimple::call(GraphCopy &GC, List<edge> &delEdges)
{
const Graph &G = GC.original();
delEdges.clear();
// We construct an auxiliary graph H which represents the current upward
// planar subgraph.
Graph H;
NodeArray<node> mapToH(G,nullptr);
NodeArray<node> mapToG(H,nullptr);
for(node v : G.nodes)
mapToG[ mapToH[v] = H.newNode() ] = v;
// We currently support only single-source acyclic digraphs ...
node s;
hasSingleSource(G,s);
OGDF_ASSERT(s != 0);
OGDF_ASSERT(isAcyclic(G));
// We start with a spanning tree of G rooted at the single source.
NodeArray<bool> visitedNode(G,false);
SListPure<edge> treeEdges;
dfsBuildSpanningTree(s,treeEdges,visitedNode);
// Mark all edges in the spanning tree so they can be skipped in the
// loop below and add (copies of) them to H.
EdgeArray<bool> visitedEdge(G,false);
SListConstIterator<edge> it;
for(it = treeEdges.begin(); it.valid(); ++it) {
edge eG = *it;
visitedEdge[eG] = true;
H.newEdge(mapToH[eG->source()],mapToH[eG->target()]);
}
// Add subsequently the remaining edges to H and test if the resulting
// graph is still upward planar. If not, remove the edge again from H
// and add it to delEdges.
SList<Tuple2<node,node> > augmented;
GraphCopySimple graphAcyclicTest(G);
for(edge eG : G.edges)
{
// already treated ?
if(visitedEdge[eG] == true)
continue;
// insert edge into H
edge eH = H.newEdge(mapToH[eG->source()],mapToH[eG->target()]);
node superSink;
SList<edge> augmentedEdges;
if (UpwardPlanarity::upwardPlanarAugment_singleSource(H,superSink,augmentedEdges) == false) {
// if H is no longer upward planar, remove eG from subgraph
H.delEdge(eH);
delEdges.pushBack(eG);
} else {
// add augmented edges as node-pair to tmpAugmented and remove
// all augmented edges from H again
SList<Tuple2<node,node> > tmpAugmented;
SListConstIterator<edge> it;
for(it = augmentedEdges.begin(); it.valid(); ++it) {
node v = mapToG[(*it)->source()];
node w = mapToG[(*it)->target()];
if (v && w)
tmpAugmented.pushBack(Tuple2<node,node>(v,w));
H.delEdge(*it);
}
if (mapToG[superSink] == nullptr)
H.delNode(superSink);
//****************************************************************
// The following is a simple workaround to assure the following
// property of the upward planar subgraph:
// The st-augmented upward planar subgraph plus the edges not
// in the subgraph must be acyclic. (This is a special property
// of the embedding, not the augmentation.)
// The upward-planar embedding function gives us ANY upward-planar
// embedding. We check if the property above holds with this
// embedding. If it doesn't, we have actually no idea if another
// embedding would do.
// The better solution would be to incorporate the acyclicity
// property into the upward-planarity test, but this is compicated.
//****************************************************************
// test if original graph plus augmented edges is still acyclic
if(checkAcyclic(graphAcyclicTest,tmpAugmented) == true) {
augmented = tmpAugmented;
} else {
// if not, remove eG from subgraph
//.........这里部分代码省略.........
示例12: Run
uint32_t Scheduler::Run()
{
ThreadLocalInfo& info = GetLocalInfo();
info.current_task = NULL;
uint32_t do_max_count = runnale_task_count_;
uint32_t do_count = 0;
Debug("Run --------------------------");
// 每次Run执行的协程数量不能多于当前runnable协程数量
// 以防wait状态的协程得不到执行。
while (do_count < do_max_count)
{
uint32_t cnt = std::max((uint32_t)1, std::min(
do_max_count / GetOptions().chunk_count,
GetOptions().max_chunk_size));
Debug("want pop %u tasks.", cnt);
SList<Task> slist = run_task_.pop(cnt);
Debug("really pop %u tasks.", cnt);
if (slist.empty()) break;
SList<Task>::iterator it = slist.begin();
while (it != slist.end())
{
Task* tk = &*it;
info.current_task = tk;
Debug("enter task(%llu)", tk->id_);
swapcontext(&info.scheduler, &tk->ctx_);
++do_count;
Debug("exit task(%llu) state=%d", tk->id_, tk->state_);
info.current_task = NULL;
switch (tk->state_) {
case TaskState::runnable:
++it;
break;
case TaskState::io_block:
case TaskState::sync_block:
--runnale_task_count_;
it = slist.erase(it);
wait_task_.push(tk);
break;
case TaskState::done:
default:
--task_count_;
--runnale_task_count_;
it = slist.erase(it);
delete tk;
break;
}
}
Debug("push %d task return to runnable list", slist.size());
run_task_.push(slist);
}
static thread_local epoll_event evs[1024];
int n = epoll_wait(epoll_fd, evs, 1024, 1);
Debug("do_count=%u, do epoll event, n = %d", do_count, n);
for (int i = 0; i < n; ++i)
{
Task* tk = (Task*)evs[i].data.ptr;
if (tk->unlink())
AddTask(tk);
}
return do_count;
}
示例13: Run
uint32_t Processer::Run(ThreadLocalInfo &info, uint32_t &done_count)
{
info.current_task = NULL;
done_count = 0;
uint32_t c = 0;
SList<Task> slist = runnable_list_.pop_all();
uint32_t do_count = slist.size();
DebugPrint(dbg_scheduler, "Run [Proc(%d) do_count:%u] --------------------------", id_, do_count);
SList<Task>::iterator it = slist.begin();
for (; it != slist.end(); ++c)
{
Task* tk = &*it;
info.current_task = tk;
tk->state_ = TaskState::runnable;
DebugPrint(dbg_switch, "enter task(%s)", tk->DebugInfo());
RestoreStack(tk);
int ret = swapcontext(&info.scheduler, &tk->ctx_);
if (ret) {
fprintf(stderr, "swapcontext error:%s\n", strerror(errno));
runnable_list_.push(tk);
ThrowError(eCoErrorCode::ec_swapcontext_failed);
}
DebugPrint(dbg_switch, "leave task(%s) state=%d", tk->DebugInfo(), tk->state_);
info.current_task = NULL;
switch (tk->state_) {
case TaskState::runnable:
++it;
break;
case TaskState::io_block:
it = slist.erase(it);
g_Scheduler.io_wait_.SchedulerSwitch(tk);
break;
case TaskState::sleep:
it = slist.erase(it);
g_Scheduler.sleep_wait_.SchedulerSwitch(tk);
break;
case TaskState::sys_block:
case TaskState::user_block:
{
if (tk->block_) {
it = slist.erase(it);
if (!tk->block_->AddWaitTask(tk))
runnable_list_.push(tk);
tk->block_ = NULL;
} else {
std::unique_lock<LFLock> lock(g_Scheduler.user_wait_lock_);
auto &zone = g_Scheduler.user_wait_tasks_[tk->user_wait_type_];
auto &wait_pair = zone[tk->user_wait_id_];
auto &task_queue = wait_pair.second;
if (wait_pair.first) {
--wait_pair.first;
tk->state_ = TaskState::runnable;
++it;
} else {
it = slist.erase(it);
task_queue.push(tk);
}
g_Scheduler.ClearWaitPairWithoutLock(tk->user_wait_type_,
tk->user_wait_id_, zone, wait_pair);
}
}
break;
case TaskState::done:
default:
--task_count_;
++done_count;
it = slist.erase(it);
DebugPrint(dbg_task, "task(%s) done.", tk->DebugInfo());
if (tk->eptr_) {
std::exception_ptr ep = tk->eptr_;
runnable_list_.push(slist);
tk->DecrementRef();
std::rethrow_exception(ep);
} else
tk->DecrementRef();
break;
}
}
if (do_count)
runnable_list_.push(slist);
return c;
}
示例14: insertEdgePathEmbedded
void UpwardPlanRep::insertEdgePathEmbedded(edge eOrig, SList<adjEntry> crossedEdges, EdgeArray<int> &costOrig)
{
removeSinkArcs(crossedEdges);
//case the copy v of eOrig->source() is a sink switch
//we muss remove the sink arcs incident to v, since after inserting eOrig, v is not a sink witch
node v = crossedEdges.front()->theNode();
List<edge> outEdges;
if (v->outdeg() == 1)
v->outEdges(outEdges); // we delete these edges later
m_eCopy[eOrig].clear();
adjEntry adjSrc, adjTgt;
SListConstIterator<adjEntry> it = crossedEdges.begin();
// iterate over all adjacency entries in crossedEdges except for first
// and last
adjSrc = *it;
List<adjEntry> dirtyList; // left and right face of the element of this list are modified
for(++it; it.valid() && it.succ().valid(); ++it)
{
adjEntry adj = *it;
bool isASourceArc = false, isASinkArc = false;
if (m_isSinkArc[adj->theEdge()])
isASinkArc = true;
if (m_isSourceArc[adj->theEdge()])
isASourceArc = true;
int c = 0;
if (original(adj->theEdge()) != nullptr)
c = costOrig[original(adj->theEdge())];
// split edge
node u = m_Gamma.split(adj->theEdge())->source();
if (!m_isSinkArc[adj->theEdge()] && !m_isSourceArc[adj->theEdge()])
crossings = crossings + c; // crossing sink/source arcs cost nothing
// determine target adjacency entry and source adjacency entry
// in the next iteration step
adjTgt = u->firstAdj();
adjEntry adjSrcNext = adjTgt->succ();
if (adjTgt != adj->twin())
std::swap(adjTgt, adjSrcNext);
edge e_split = adjTgt->theEdge(); // the new split edge
if (e_split->source() != u)
e_split = adjSrcNext->theEdge();
if (isASinkArc)
m_isSinkArc[e_split] = true;
if (isASourceArc)
m_isSourceArc[e_split] = true;
// insert a new edge into the face
edge eNew = m_Gamma.splitFace(adjSrc,adjTgt);
m_eIterator[eNew] = GraphCopy::m_eCopy[eOrig].pushBack(eNew);
m_eOrig[eNew] = eOrig;
dirtyList.pushBack(eNew->adjSource());
adjSrc = adjSrcNext;
}
// insert last edge
edge eNew = m_Gamma.splitFace(adjSrc,*it);
m_eIterator[eNew] = m_eCopy[eOrig].pushBack(eNew);
m_eOrig[eNew] = eOrig;
dirtyList.pushBack(eNew->adjSource());
// remove the sink arc incident to v
if(!outEdges.empty()) {
edge e = outEdges.popFrontRet();
if (m_isSinkArc[e])
m_Gamma.joinFaces(e);
}
m_Gamma.setExternalFace(m_Gamma.rightFace(extFaceHandle));
//computeSinkSwitches();
FaceSinkGraph fsg(m_Gamma, s_hat);
List<adjEntry> dummyList;
FaceArray< List<adjEntry> > sinkSwitches(m_Gamma, dummyList);
fsg.sinkSwitches(sinkSwitches);
//construct sinkArc for the dirty faces
for(adjEntry adj : dirtyList) {
face fLeft = m_Gamma.leftFace(adj);
face fRight = m_Gamma.rightFace(adj);
List<adjEntry> switches = sinkSwitches[fLeft];
OGDF_ASSERT(!switches.empty());
constructSinkArcs(fLeft, switches.front()->theNode());
OGDF_ASSERT(!switches.empty());
switches = sinkSwitches[fRight];
constructSinkArcs(fRight, switches.front()->theNode());
//.........这里部分代码省略.........
示例15: expandLowDegreeVertices
void PlanRep::expandLowDegreeVertices(OrthoRep &OR)
{
for(node v : nodes)
{
if (!(isVertex(v)) || expandAdj(v) != nullptr)
continue;
SList<edge> adjEdges;
SListPure<Tuple2<node,int> > expander;
node u = v;
bool firstTime = true;
setExpandedNode(v, v);
for(adjEntry adj : v->adjEdges) {
adjEdges.pushBack(adj->theEdge());
if(!firstTime)
u = newNode();
setExpandedNode(u, v);
typeOf(u) = Graph::lowDegreeExpander;
expander.pushBack(Tuple2<node,int>(u,OR.angle(adj)));
firstTime = false;
}
SListConstIterator<Tuple2<node,int>> itn = expander.begin().succ();
for (SListConstIterator<edge> it = adjEdges.begin().succ(); it.valid(); ++it)
{
// Did we allocate enough dummy nodes?
OGDF_ASSERT(itn.valid());
if ((*it)->source() == v)
moveSource(*it,(*itn).x1());
else
moveTarget(*it,(*itn).x1());
++itn;
}
adjEntry adjPrev = v->firstAdj();
itn = expander.begin();
int nBends = (*itn).x2();
for (++itn; itn.valid(); ++itn)
{
edge e = newEdge(adjPrev,(*itn).x1()->firstAdj());
OR.bend(e->adjSource()).set(convexBend,nBends);
OR.bend(e->adjTarget()).set(reflexBend,nBends);
OR.angle(adjPrev) = 1;
OR.angle(e->adjSource()) = 2;
OR.angle(e->adjTarget()) = 1;
nBends = (*itn).x2();
typeOf(e) = association; //???
setExpansionEdge(e, 2);
adjPrev = (*itn).x1()->firstAdj();
}
edge e = newEdge(adjPrev,v->lastAdj());
typeOf(e) = association; //???
setExpansionEdge(e, 2);
expandAdj(v) = e->adjSource();
OR.bend(e->adjSource()).set(convexBend,nBends);
OR.bend(e->adjTarget()).set(reflexBend,nBends);
OR.angle(adjPrev) = 1;
OR.angle(e->adjSource()) = 2;
OR.angle(e->adjTarget()) = 1;
}
}//expandlowdegreevertices