本文整理汇总了C++中SList类的典型用法代码示例。如果您正苦于以下问题:C++ SList类的具体用法?C++ SList怎么用?C++ SList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLaneParentsChilds
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;
}
示例2: CheckIntersect
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;
}
示例3: fsg
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();
}
示例4: test_pop_front
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;
}
示例5: unify
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);
}
}
示例6: test_push_front
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;
}
示例7: test_pop_back
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;
}
示例8: 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;
}
示例9: test_reverse
void test_reverse(Test* test)
{
SList* list = new SList("hello","wordl");
list->push_back("hi");
list->push_back("why");
(*list).reverse();
delete list;
}
示例10: reverse
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);
}
示例11: main
int main() {
SList ls;
ls.Insert(8);
ls.Insert(5);
ls.Insert(4);
ls.Insert(1);
ls.Traversal();
ls.ReverseTraversal();
}
示例12: run
void FrontIsEmpty::run()
{
SList newList;
try {
string str = newList.front();
fail();
} catch (logic_error&) {
pass();
}
}
示例13: StealHalf
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;
}
示例14: test_swap
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_;
}
示例15: 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;
}