void CFolderCrawler::RemoveDuplicate(std::deque<CTGitPath> &list,const CTGitPath &path) { for (auto it = list.cbegin(); it != list.cend(); ++it) { if(*it == path) { list.erase(it); it = list.cbegin(); /* search again*/ if (it == list.cend()) break; } } }
ChinesePostman::EdgeWeightType sum_of_distance(const std::deque<ChinesePostman::SubRoute> & route){ ChinesePostman::EdgeWeightType result = 0; for(auto it = route.cbegin(); it != route.cend(); ++it){ result += it->weight; } return result; }
void bad_erase_deque1(std::deque<int> &D) { auto i2 = D.cbegin(), i0 = i2++, i1 = i2++; D.erase(i1); *i0; // expected-warning{{Invalidated iterator accessed}} *i1; // expected-warning{{Invalidated iterator accessed}} *i2; // expected-warning{{Invalidated iterator accessed}} }
msgBase::ptr LaunchBallRequest::interpretPacket( const std::deque<char>& _buffer ) { LaunchBallRequest::ptr egr = LaunchBallRequest::ptr(new LaunchBallRequest()); std::deque<char>::const_iterator it = _buffer.cbegin(); it = unpack(egr->msgHeader, it); it = unpack(egr->gType, it); return egr; }
msgBase::ptr AcknowledgeLast::interpretPacket( const std::deque<char>& _buffer ) { AcknowledgeLast::ptr rc = AcknowledgeLast::ptr(new AcknowledgeLast()); std::deque<char>::const_iterator it = _buffer.cbegin(); it = unpack(rc->msgHeader, it); it = unpack(rc->ackBool, it); it = unpack(rc->ackType, it); return rc; }
msgBase::ptr EndGameResponse::interpretPacket( const std::deque<char>& _buffer ) { EndGameResponse::ptr egr = EndGameResponse::ptr(new EndGameResponse()); std::deque<char>::const_iterator it = _buffer.cbegin(); it = unpack(egr->msgHeader, it); it = unpack(egr->gType, it); it = unpack(egr->res, it); return egr; }
msgBase::ptr PaddleUpdateRequest::interpretPacket( const std::deque<char>& _buffer ) { PaddleUpdateRequest::ptr pur = PaddleUpdateRequest::ptr(new PaddleUpdateRequest()); std::deque<char>::const_iterator it = _buffer.cbegin(); it = unpack(pur->msgHeader, it); it = unpack(pur->gType, it); it = unpack(pur->p, it); return pur; }
std::string print_results (std::deque<T> const& l) { std::stringstream out; if (not l.empty()) { out << "["; for (auto it = l.cbegin(); it != std::prev(l.cend()); ++it) out << fnk::utility::to_string<T> (*it) + ", "; out << fnk::utility::to_string<T>(l.back()) + "]"; } else out << "[]"; return out.str(); }
void PictFrame::selectPhotos(const std::deque<YString>& pool) { unsigned int poolSize = static_cast<unsigned int>(pool.size()); // TODO Adjust the message when not enough photos... logs.notice() << "There are " << poolSize << " photos in the pool; " << "among which " << pNbPhotos << " will be selected"; if (poolSize <= pNbPhotos) { // Trivial case: keep all photos! for (auto it = pool.cbegin(), end = pool.cend(); it != end; ++it) { ExtendedPhoto::ExtendedPhoto::Ptr ptr = new ExtendedPhoto::ExtendedPhoto(logs, pCameras, *it); pPhotosChosen.push_back(ptr); } } else { std::vector<unsigned int> randomSequence; // Select semi-randomly a subset of indexes between 0 and poolSize - 1 semiRandomSubset(randomSequence, poolSize, pNbPhotos); GenericTools::printContainer(std::cout, randomSequence, ", ", "Random sequence is: ", "\n"); { // Finally create the list from the index generated above for (auto it = randomSequence.cbegin(), end = randomSequence.cend(); it != end; ++it) { assert(*it < poolSize); ExtendedPhoto::ExtendedPhoto::Ptr ptr = new ExtendedPhoto::ExtendedPhoto(logs, pCameras, pool[*it]); pPhotosChosen.push_back(ptr); } } } }
void good_pop_front_deque1(std::deque<int> &D, int n) { auto i1 = D.cbegin(), i0 = i1++; D.pop_front(); *i1; // no-warning }
void bad_push_back_deque1(std::deque<int> &D, int n) { auto i0 = D.cbegin(), i1 = D.cend(); D.push_back(n); *i0; // expected-warning{{Invalidated iterator accessed}} --i1; // expected-warning{{Invalidated iterator accessed}} }
/** * Iterate over the futures of all posted jobs. * Iteration occurs in the order the jobs were added. */ const_iterator cbegin() const{ return futures.cbegin(); }
void bad_pop_back_deque1(std::deque<int> &D, int n) { auto i0 = D.cbegin(), i1 = D.cend(), i2 = i1--; D.pop_back(); *i1; // expected-warning{{Invalidated iterator accessed}} --i2; // expected-warning{{Invalidated iterator accessed}} }
void good_pop_back_deque1(std::deque<int> &D, int n) { auto i0 = D.cbegin(), i1 = D.cend(), i2 = i1--; D.pop_back(); *i0; // no-warning }
void bad_assign_deque1(std::deque<int> &D, int n) { auto i0 = D.cbegin(); D.assign(10, n); *i0; // expected-warning{{Invalidated iterator accessed}} }
void bad_clear_deque1(std::deque<int> &D) { auto i0 = D.cbegin(), i1 = D.cend(); D.clear(); *i0; // expected-warning{{Invalidated iterator accessed}} --i1; // expected-warning{{Invalidated iterator accessed}} }
void bad_copy_assign_operator_deque1(std::deque<int> &D1, const std::deque<int> &D2) { auto i0 = D1.cbegin(); D1 = D2; *i0; // expected-warning{{Invalidated iterator accessed}} }
void bad_emplace_deque1(std::deque<int> &D, int n) { auto i1 = D.cbegin(), i0 = i1++; D.emplace(i1, n); *i0; // expected-warning{{Invalidated iterator accessed}} *i1; // expected-warning{{Invalidated iterator accessed}} }
void bad_pop_front_deque1(std::deque<int> &D, int n) { auto i1 = D.cbegin(), i0 = i1++; D.pop_front(); *i0; // expected-warning{{Invalidated iterator accessed}} }
///////////////////////////////////////////////////////////////////////////////////////// // Queue::begin/end const //! Retrieve immutable start/end iterators //! //! \return const_iterator - Position of first/last elements ///////////////////////////////////////////////////////////////////////////////////////// const_iterator begin() const { return Items.cbegin(); }
void bad_emplace_front_deque1(std::deque<int> &D, int n) { auto i0 = D.cbegin(), i1 = D.cend(); D.emplace_front(n); *i0; // expected-warning{{Invalidated iterator accessed}} --i1; // expected-warning{{Invalidated iterator accessed}} }