void DataPlot::push(std::vector<SensorValues> sensors, bool left) { if (left) for (std::vector<SensorValues>::reverse_iterator it = sensors.rbegin(); it != sensors.rend(); it++) push(*it, left); else for (std::vector<SensorValues>::iterator it = sensors.begin(); it != sensors.end(); it++) push(*it, left); }
void SplitString(const std::string& str, const char delim, std::vector<std::string>& output) { std::istringstream iss(str); output.resize(1); while (std::getline(iss, *output.rbegin(), delim)) output.push_back(""); output.pop_back(); }
void SpinAdapted::SaveRotationMatrix (const std::vector<int>& sites, const std::vector<Matrix>& m1, int state) { Timer disktimer; int rank = mpigetrank(); if (rank == 0) { char file [5000]; int first = min(sites[0], *sites.rbegin()), last = max(sites[0], *sites.rbegin()); if (state == -1) sprintf (file, "%s%s%d%s%d%s%d%s", dmrginp.save_prefix().c_str(), "/Rotation-", first, "-", last, ".", mpigetrank(),".state_average.tmp"); else sprintf (file, "%s%s%d%s%d%s%d%s%d%s", dmrginp.save_prefix().c_str(), "/Rotation-", first, "-", last, ".", mpigetrank(),".state",state, ".tmp"); p1out << "\t\t\t Saving Rotation Matrix :: " << file << endl; std::ofstream ofs(file, std::ios::binary); boost::archive::binary_oarchive save_mat(ofs); save_mat << m1; ofs.close(); } }
MatchedInvocationHandler* getInvocationHandlerForActualArgs(ActualInvocation<arglist...>& invocation) { for (auto i = _invocationHandlers.rbegin(); i != _invocationHandlers.rend(); ++i) { std::shared_ptr<Destructable> curr = *i; Destructable& Destructable = *curr; MatchedInvocationHandler& im = asMatchedInvocationHandler(Destructable); if (im.getMatcher().matches(invocation)) { return &im; } } return nullptr; }
/// \param[in] t_params the list of params to search /// \param[in] t_value the value to search for /// \returns the JobParam matching the given value. Throws an exception if it is not found static bool hasByValue(const std::vector<JobParam> &t_params, const std::string &t_value) { auto itr = std::find_if(t_params.rbegin(), t_params.rend(), JobParamValueCompare(t_value)); if (itr != t_params.rend()) { return true; } return false; }
bool Codegen::generateCallIA32(Address addr, const std::vector<Address> &args) { for (auto iter = args.rbegin(); iter != args.rend(); ++iter) { copyByte(0x68); copyInt(*iter); } unsigned offset = addr - (buffer_.curAddr() + 5); copyByte(0xe8); copyInt(offset); return true; }
/* * Confirm all actions were released in the correct order */ void confirmReleaseActionHistoryOrder(std::vector<MockUndoActionHistory*> histories, int &expectedStartingIndex) { for (std::vector<MockUndoActionHistory*>::reverse_iterator i = histories.rbegin(); i != histories.rend(); i++) { const MockUndoActionHistory *history = *i; ASSERT_TRUE(history->m_released); ASSERT_FALSE(history->m_undone); ASSERT_EQ(history->m_releasedIndex, expectedStartingIndex); expectedStartingIndex++; } }
void PerformanceRecordTreeWidget::collectVisibleParentPerformanceSamples() { std::map<std::string, PerformanceSample> tempSampleMap; std::map<std::string, PerformanceSample>::iterator tempSampleMapIterator; std::vector<PerformanceSample*>::const_reverse_iterator sampleReverseVectorIterator; std::string lastName; if(performanceRecordWidget_) { std::vector<const PerformanceRecord*> records = performanceRecordWidget_->collectPerformanceRecords(); performanceSamples_.clear(); foreach(const PerformanceRecord* record, records) { if(QString::fromStdString(record->getName()).indexOf(QString::fromStdString(filterText_), 0, Qt::CaseInsensitive) != -1){ tempSampleMap.clear(); const std::vector<PerformanceSample*> samples = record->getSamples(); PerformanceSample parent_sample(NULL, record->getName()); if(!averageTime_){ if(samples.size()>0){ sampleReverseVectorIterator = samples.rbegin(); lastName = samples.back()->getName(); while(sampleReverseVectorIterator < samples.rend() && (samples.rbegin() == sampleReverseVectorIterator || (*sampleReverseVectorIterator)->getName() != lastName)){ parent_sample.addChild(*(*sampleReverseVectorIterator)); ++sampleReverseVectorIterator; } } } else{ foreach(PerformanceSample* sample, samples){ tempSampleMapIterator = tempSampleMap.lower_bound(sample->getName()); if(tempSampleMapIterator != tempSampleMap.end() && !(tempSampleMap.key_comp()(sample->getName(), tempSampleMapIterator->first))){ tempSampleMapIterator->second = tempSampleMapIterator->second + (*sample); } else { tempSampleMap.insert(std::pair<std::string, PerformanceSample>(sample->getName(), (*sample))); } } for (tempSampleMapIterator=tempSampleMap.begin() ; tempSampleMapIterator != tempSampleMap.end(); tempSampleMapIterator++){ PerformanceSample* child_sample = parent_sample.addChild(tempSampleMapIterator->second); child_sample->normalize(); } } performanceSamples_.push_back(parent_sample); } }
void ConnectionManager::disconnectAll(std::vector<ConnectionNode>& connections, ossie::DomainLookup* domainLookup) { // Disconnect all connections made for the application in the reverse order of their creation. LOG_TRACE(ConnectionManager, "Disconnecting " << connections.size() << " ports"); for (std::vector<ConnectionNode>::reverse_iterator connection = connections.rbegin(); connection != connections.rend(); ++connection) { LOG_TRACE(ConnectionManager, "Disconnecting connection " << connection->identifier); connection->disconnect(domainLookup); } connections.clear(); LOG_TRACE(ConnectionManager, "All connected ports disconnected"); }
void tearDownCache() { for (std::vector<Transfer::CacheLayer*>::reverse_iterator iter = mCacheLayers.rbegin(); iter != mCacheLayers.rend(); ++iter) { delete (*iter); } mCacheLayers.clear(); for (std::vector<Transfer::CachePolicy*>::iterator iter = mCachePolicy.begin(); iter != mCachePolicy.end(); ++iter) { delete (*iter); } mCachePolicy.clear(); }
bool find( const T &t ) { extern bool intersects( const T &t1, const T &t2 ); std::vector<T>::reverse_iterator it = family.rbegin(), end = family.rend(); for( ; it != end ; ++it ) if( intersects(*it, t) ) return search = it, true; return search = end, false; }
void Selection::setReprList(std::vector<XML::Node*> const &list) { _clear(); for ( std::vector<XML::Node*>::const_reverse_iterator iter=list.rbegin();iter!=list.rend(); ++iter) { SPObject *obj=_objectForXMLNode(*iter); if (obj) { _add(obj); } } _emitChanged(); }
// We want a vector with the integer offset of each field relative to the righthand end of the panel void SBPanel::BuildFieldOffsets(const std::vector<int>& fldWidths) { int cum = 0; // Add up field widths starting at right end of panel for (auto it = fldWidths.rbegin(); it != fldWidths.rend(); it++) { cum += *it; fieldOffsets.push_back(cum); } // Reverse it because the fields are indexed from left to right std::reverse(fieldOffsets.begin(), fieldOffsets.end()); }
void DistributeRemaining() { std::sort(m_Result.begin(), m_Result.end()); for(std::vector<DistributionElem>::reverse_iterator it = m_Result.rbegin(); it != m_Result.rend(); ++it) { if(m_iResultingWorkers == m_iAllWorkers) return; ++m_iResultingWorkers; it->m_iCount++; } AssertBotE(false); }
std::vector<int> next_palindrome( std::vector<int>& number ) { if( number.empty() ) return {1} ; auto mid = ( number.size() ) / 2 ; auto begin = number.begin() ; if( std::all_of( begin, begin+mid, [] ( int v ) { return v==9 ; } ) ) { for( int& v : number ) v = 0 ; number.push_back(1) ; number.front() = 1 ; return number ; } auto iter = number.rbegin() + mid ; while( *iter == 9 ) { *iter = 0 ; ++iter ; } ++ *iter ; std::copy( number.rbegin()+mid, number.rend(), number.begin()+mid ) ; return number ; }
bool LvalExpr::check() { for(std::vector<ctx>::reverse_iterator it = ctstack.rbegin(); it != ctstack.rend(); it++) { ctx::iterator varit = it->find(name); if (varit != it->end()) return true; } yyerror(&loc, 0, (char*)("Variable not defined: " + name).c_str()); exit(-1); return false; }
//Wang-Landau:upper bound bean, returns position of the highest occupied energy level int upper_bound_bean(std::vector<double>& DOS, Bean bean, double InitialDOS, int last, double end_f) { int distance = -1; int size = DOS.size(); double const LogInitialDOS = log(InitialDOS); int upper_bound = 0; int dE; dE = bean.range() + 1; //+1 takes into account the 0 because E goes from -dE to +dE; if (last > dE) { std::cerr<<"error: lower bound bean: search parameter 'last' exceeds the size of the vector"<<std::endl; exit (EXIT_FAILURE); } std::vector<double>::reverse_iterator rit_last = DOS.rbegin(); rit_last += last; for (std::vector<double>::reverse_iterator rit = DOS.rbegin(); rit != rit_last; ++rit) { if(*rit >= (LogInitialDOS + end_f) ) { distance = std::distance(DOS.rbegin(), rit); break; } } upper_bound = (int) ( (size-1) - distance); //size-1 because size is n+1 where n is the distance from 0 //std::cout<<"DEBUG DOS.at(upper_bound)= " <<DOS.at(upper_bound)<<std::endl; if(upper_bound <= size && upper_bound != 0) return upper_bound; else { std::cerr<<"error: upper_bound not found, redefine the range of search for the lower bound"<<std::endl; exit (EXIT_FAILURE); } }
combinations_with_replacement_iter & operator++() { for (auto iter = indicies.rbegin(); iter != indicies.rend(); ++iter) { ++(*iter); if (*iter == std::end(items)) { if ( (iter + 1) != indicies.rend()) { for (auto down = iter; down != indicies.rbegin()-1;--down) { (*down) = (*(iter + 1)) + 1; } } else { not_done = false; break; } } else break; //we break because none of the rest of the items need to //be incremented } return *this; }
void Fleet::setPath(const std::vector<std::pair<int, int>>& ppath) { if (ppath.size() > 0) { path.clear(); path.reserve(ppath.size()); for (auto it = ppath.rbegin(); it < ppath.rend() - 1; it++) // Skip the last, as it's 0,0. { path.push_back(*it); } } }
//----------------------------------------------------------------------------- bool FileManager::findFile(std::string& full_path, const std::string& fname, const std::vector<std::string>& search_path) const { for(std::vector<std::string>::const_reverse_iterator i = search_path.rbegin(); i != search_path.rend(); ++i) { full_path = *i + "/" + fname; if(m_file_system->existFile(full_path.c_str())) return true; } full_path=""; return false; } // findFile
//! Exercise 10.37: //! Given a vector that has ten elements, copy the elements from positions //! 3 through 7 in reverse order to a list. inline void vec2list_3_7_reverse(const std::vector<int> &v, std::list<int> &l) { //! 1 2 3 4 5 6 7 8 9 10 //! ^ ^^ //! rend rbegin std::copy(v.rbegin() + 3, v.rend() - 2, std::back_inserter(l)); //! ^ //! @note: std::copy copies the range [first,last) into result. //! hence, the arguments here denote: //! [7 6 5 4 3 2) //! ^ this one is specified but not included. }
void MadEdit::CalcEOLMarkPoints(std::vector<wxPoint>& dest, const std::vector<wxPoint>& src, const wxSize& charsz) { const int maxX = src.rbegin()->x; const int maxY = src.rbegin()->y; dest.clear(); const size_t cnt = src.size() - 1; for (size_t i = 0; i< cnt; ++i) { int x = (int)round(1.0 * charsz.x * src[i].x / maxX); int y = (int)round(1.0 * charsz.y * src[i].y / maxY); dest.push_back(wxPoint(x, y)); } }
std::string join(const std::vector<std::string>& elements, const char* separator) { switch (elements.size()) { case 0: return ""; case 1: return elements[0]; default: std::ostringstream os; std::copy(elements.begin(), elements.end() - 1, std::ostream_iterator<std::string>(os, separator)); os << *elements.rbegin(); return os.str(); } }
inline void Puzzle::dlxUnfilterRow() { DlxNode* row = *filterList.rbegin(); filterList.pop_back(); register DlxNode* n = row; do { ++n->head->numRow; n->down->up = n; n->up->down = n; n = n->left; } while(n != row); }
/* internal do the instrumentation module */ static void insert_into_buffer (paje_event_t tbi) { if (TRACE_buffer() == 0){ tbi->print (tbi); tbi->free (tbi); return; } XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", __FUNCTION__, (int)tbi->event_type, tbi->timestamp, buffer.size()); std::vector<paje_event_t>::reverse_iterator i; for (i = buffer.rbegin(); i != buffer.rend(); ++i) { paje_event_t e1 = *i; if (e1->timestamp <= tbi->timestamp) break; } buffer.insert(i.base(), tbi); if (i == buffer.rend()) XBT_DEBUG("%s: inserted at beginning", __FUNCTION__); else XBT_DEBUG("%s: inserted at%s %zd", __FUNCTION__, (i == buffer.rbegin()) ? " end" :"pos =", std::distance(buffer.rend(),i)); }
JITSymbol findMangledSymbol(const std::string &Name) { // Search modules in reverse order: from last added to first added. // This is the opposite of the usual search order for dlsym, but makes more // sense in a REPL where we want to bind to the newest available definition. for (auto H : make_range(module_handles.rbegin(), module_handles.rend())) if (auto Sym = ir_compile_layer.findSymbolIn(H, Name, true)) return Sym; // If we can't find the symbol in the JIT, try looking in the host process. //if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess(Name)) // return JITSymbol(SymAddr, JITSymbolFlags::Exported); return nullptr; }
void determineIslandsPerLevel(std::vector<int>& islands_per_level) { std::vector<int>::reverse_iterator tmpIslandsIter = islands_per_level.rbegin(); int tmp = *tmpIslandsIter; std::vector<int>::reverse_iterator curIslandsIter = tmpIslandsIter; ++curIslandsIter; while(curIslandsIter != islands_per_level.rend() ) { *curIslandsIter += tmp; if (*curIslandsIter) { tmp = *curIslandsIter; } ++curIslandsIter; } }
void process(std::vector<int> &v) { std::vector<int> vv; for(auto it = v.begin(); it != v.end(); ++it) { ++it; if(it != v.end()) vv.push_back(*it); else break; } v = vv; std::copy(v.rbegin(), v.rend(), std::ostream_iterator<int>(std::cout, " ")); }
std::vector<String> FilePath::simplifyUpsInParts(const std::vector<String>& parts) { if (parts.empty()) return {}; std::vector<String> result(simplifiedSize(parts)); auto lastUpIt = std::find(parts.rbegin(), parts.rend(), upString); auto destIt = std::copy(parts.rbegin(), lastUpIt, result.rbegin()); unsigned upsCount = 0; for (auto it = lastUpIt; it != parts.rend(); ++it) { if (*it == upString) ++upsCount; else { if (upsCount == 0) *(destIt++) = *it; else --upsCount; } } std::fill_n(destIt, upsCount, upString); return result; }
PotentialStepped::PotentialStepped(std::vector<std::pair<double, double> > steps, bool direction): _direction(direction) { if (direction) std::sort(steps.begin(), steps.end()); else std::sort(steps.rbegin(), steps.rend()); for (size_t i(0); i < steps.size(); ++i) { _r_cache.push_back(steps[i].first); _u_cache.push_back(steps[i].second); } }