当前位置: 首页>>代码示例>>C++>>正文


C++ TList::begin方法代码示例

本文整理汇总了C++中TList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::begin方法的具体用法?C++ TList::begin怎么用?C++ TList::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TList的用法示例。


在下文中一共展示了TList::begin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    int i, x;
    TList<int> L;

    for (i = 0; i < 10; ++i)
    {
        x = i*i;
        L.push_front(x); // mit Quadratzahlen füllen
    }

    TList<int>::Iterator ListIter(L);

    cout << "*ListIter = " << *ListIter << endl;
    cout << "ListIter++;" << endl;
    ListIter++;
    cout << "*ListIter = " << *ListIter << endl;

   // 36 löschen, falls vorhanden
   while(ListIter++ != L.end())
      if (*ListIter == 36)
      {
         cout << *ListIter << " wird geloescht\n";
         L.erase(ListIter);
         cout << *ListIter
              << " an aktueller Position\n";
         break;
      }

   int target = 3;
   int count = 0;

   TList<int>::Iterator it = L.begin();
   while (it != L.end()) {
       if (count == target) {
           std::cout << "bam" << *it << std::endl;
       }
       count++;
       it++;
   }

   //for (TList<int>::Iterator iter = L.begin(); iter != L.end(); i++) {
   //    std::cout << *iter << std::endl;
   //}

   //TList<int>::Iterator it = L.begin();
   //while (it != L.end()) {
   //    std::cout << *it << std::endl;
   //    it++;
   //}
   for (TList<int>::Iterator itt = L.begin(); itt != L.end(); ++itt) {
       std::cout << *itt << " ";
   }
   

    return 0;
}
开发者ID:SteveCharleston,项目名称:cpp,代码行数:57,代码来源:list.cpp

示例2: TList

 TList(const TList<T, Allocator> &list) {
     begin_ = nullptr;
     end_ = nullptr;
     size_ = 0;
     for (TConstListIterator it = list.begin(); it != list.end(); ++it) {
         push_back(*it);
     }
 }
开发者ID:AlmazNasibullin,项目名称:Shad_Algorithms,代码行数:8,代码来源:list.hpp

示例3: DoTestInsertRemoveEmpty

std::string DoTestInsertRemoveEmpty(size_t n) {
    TCounter::Reset();
    {
        TList<TCounter, std::allocator<TCounter>> lst;
        for (size_t i = 0; i < n; ++i) {
            TList<TCounter, std::allocator<TCounter>>::iterator it = lst.begin();
            for (size_t j = 0; j < i / 2; ++j)
                ++it;
            lst.insert(it, TCounter());
        }
        if (lst.size() != n)
            return "lst.size(): wrong answer";
        while (!lst.empty())
            lst.erase(lst.begin());
    }
    TCounter::CheckTotalOperationsCount(n * 5 + 100, n + 100);
    return TCounter::GetAllErrors();
}
开发者ID:filaPro,项目名称:my,代码行数:18,代码来源:03.cpp

示例4:

be_ArgumentList::be_ArgumentList(const TList<be_argument*>& oldlist)
{
   TList<be_argument*>::iterator iter;

   for (iter = oldlist.begin(); iter != oldlist.end(); ++iter)
   {
      const be_argument& arg = *(*iter);
      push_back(be_Argument(arg));
   }
}
开发者ID:diorahman,项目名称:opensplice,代码行数:10,代码来源:xbe_arglist.cpp

示例5: merge

 void merge(TList<T, Allocator> &list) {
     if (&list == this) {
         return;
     }
     TListIterator firstIter = begin();
     TListIterator secondIter = list.begin();
     while (firstIter != end() && secondIter != list.end()) {
         if (*firstIter < *secondIter) {
             ++firstIter;
         } else {
             insert(firstIter, *secondIter);
             list.erase(secondIter);
             secondIter = list.begin();
         }
     }
     while (secondIter != end()) {
         insert(firstIter, *secondIter);
         list.erase(secondIter);
         secondIter = list.begin();
     }
 }
开发者ID:AlmazNasibullin,项目名称:Shad_Algorithms,代码行数:21,代码来源:list.hpp

示例6: CascadeTimers

int TimerMaster::CascadeTimers(TimerVec *v, int index) {
  TList *l = &(*v)[index];
  for (TList::iterator it = l->begin();
       it != l->end();) {
    TimerSlot *s = &*it;
    ++it;
    s->unlink();
    InternalAddTimer(s, s->weak_timer, s->jiffies);
  }
  CHECK(l->empty());
  return index;
}
开发者ID:0xec,项目名称:server1,代码行数:12,代码来源:timer_master.cpp

示例7: DestroyAllTimers

void TimerMaster::DestroyAllTimers() {
  for (int i = 0; i < arraysize(vecs_); ++i) {
    for (int j = 0; j < kTVSize; ++j) {
      TList *l = &vecs_[i][j];
      for (TList::iterator it = l->begin(); it != l->end();) {
        TimerSlot *s = &*it;
        ++it;
        delete s;
      }
    }
  }
}
开发者ID:0xec,项目名称:server1,代码行数:12,代码来源:timer_master.cpp

示例8: begin

 bool operator ==(const TList<T, Allocator> &list) const {
     if (size_ != list.size()) {
         return false;
     }
     TConstListIterator first = begin();
     TConstListIterator second = list.begin();
     for (; first != end(); ++first, ++second) {
         if (*first != *second) {
             return false;
         }
     }
     return true;
 }
开发者ID:AlmazNasibullin,项目名称:Shad_Algorithms,代码行数:13,代码来源:list.hpp

示例9: Update

void TimerMaster::Update(int jiffies) {
  CHECK_GE(jiffies, timer_jiffies_);
  TimerVec &v0 = vecs_[0];
  while (jiffies - timer_jiffies_ >= 0) {
    vector<pair<TimerSlot*, boost::shared_ptr<Timer> > > timers;
    {
      boost::mutex::scoped_lock lock(mutex_);
      const int index = timer_jiffies_ & kTVMask;
      if (!index && !CascadeTimers(&vecs_[1], INDEX(1)) &&
          !CascadeTimers(&vecs_[2], INDEX(2))) {
        CascadeTimers(&vecs_[3], INDEX(3));
      }
      TList *l = &v0[index];
      for (TList::iterator it = l->begin();
           it != l->end();) {
        TimerSlot *s = &*it;
        ++it;
        s->unlink();
        boost::weak_ptr<Timer> weak_timer = s->weak_timer;
        boost::shared_ptr<Timer> timer = weak_timer.lock();
        if (weak_timer.expired()) {
          delete s;
          continue;
        }
        timers.push_back(make_pair(s, timer));
      }
    }
    const int old_timer_jiffies = timer_jiffies_;
    ++timer_jiffies_;
    for (vector<pair<TimerSlot*, boost::shared_ptr<Timer> > >::iterator it =
         timers.begin(); it != timers.end(); ++it) {
      it->second->Expired();
    }
    {
      for (int i = 0; i < timers.size(); ++i) {
        TimerSlot *s = timers[i].first;
        boost::shared_ptr<Timer> timer = timers[i].second;
        if (timer->period()) {
          boost::mutex::scoped_lock lock(mutex_);
          InternalAddTimer(s, timer, timer->timeout() + old_timer_jiffies);
        } else {
          delete s;
        }
      }
    }
  }
}
开发者ID:0xec,项目名称:server1,代码行数:47,代码来源:timer_master.cpp


注:本文中的TList::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。