本文整理汇总了C++中SList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::end方法的具体用法?C++ SList::end怎么用?C++ SList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::end方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
}
示例6: 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;
}
示例7: 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;
}