PresentationOrderSampleMap::reverse_iterator PresentationOrderSampleMap::reverseFindSampleContainingPresentationTime(const MediaTime& time) { auto range = std::equal_range(rbegin(), rend(), time, SampleIsGreaterThanMediaTimeComparator<MapType>()); if (range.first == range.second) return rend(); return range.first; }
const_reverse_iterator rfind(value_type const& v) const { const_reverse_iterator i(std::upper_bound(rbegin(), rend(), v, compose_binary(std::logical_not<bool>(), static_cast<TweakOrdering_ const&>(ord_)))); return i != rend() && *i == v ? i: rend(); }
// --------------------------------------------------------------------------------------- // FUNCTION: CString::TrimRight // CString& TrimRight(); // // DESCRIPTION: // This function removes any whitespace characters from the right end of the string. // // PARAMETERS: none // RETURN VALUE: // a reference to this object (*this) -- allows chaining together of // these calls, eg. strTest.TrimRight().TrimLeft().ToUpper(); // --------------------------------------------------------------------------------------- CString& CString::TrimRight() { CString::reverse_iterator iter = std::find_if(rbegin(), rend(), NotSpace()); if ( iter != rend() ) { CString::size_type nNewSize = find_last_of(*iter); erase(nNewSize+1); } else { erase(); } return *this; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //! return list of qcParameters for the last n seconds in buffer const QcBuffer* QcBuffer::qcParameter(const Core::TimeSpan& lastNSeconds) const { QcBuffer* qcb = new QcBuffer(); if (empty()) return qcb; const_reverse_iterator Start = rbegin(); const_reverse_iterator End = rbegin(); for (const_reverse_iterator qcPar = rbegin(); qcPar != rend(); qcPar++) { if (!(*qcPar)) continue; Core::TimeSpan diff = back()->recordEndTime - (*qcPar)->recordEndTime; Start = qcPar; if ( diff > lastNSeconds ) break; } if (Start != End) { qcb->insert(qcb->begin(), End, Start); qcb->reverse(); } return qcb; }
CItem* CItemList::find(const QPoint& pos) const/*{{{*/ { rciCItem ius; bool usfound = false; for (rciCItem i = rbegin(); i != rend(); ++i) { if (i->second->contains(pos)) { if (i->second->isSelected()) return i->second; else { if (!usfound) { ius = i; usfound = true; } } } } if (usfound) return ius->second; else return 0; }/*}}}*/
void PipeLine::cancel_last_packet_reservation(std::shared_ptr<Frame> frame) { auto slack = frame->slack_interval(); auto interval_res = reservations_in_interval(slack); auto result = std::find_if(interval_res.rbegin(), interval_res.rend(), [frame](const pipeline_datatype& pair) -> bool {return frame == pair.second;} ); cancel_reservation(slack.second - 1 - std::distance(interval_res.rbegin(), result)); }
uint32 RangeSet::getLast() const { const_reverse_iterator it = rbegin(); if (it == rend()) return RangeSetAbsent; return upper(it); }
static void test_posix_dup() { int pfd[2]; BOOST_REQUIRE(::pipe(pfd) != -1); bpd::file_handle rend(pfd[0]); bpd::file_handle wend(pfd[1]); BOOST_REQUIRE(rend.get() != 10); BOOST_REQUIRE(wend.get() != 10); bpd::file_handle fh1 = bpd::file_handle::posix_dup(wend.get(), 10); BOOST_REQUIRE_EQUAL(fh1.get(), 10); BOOST_REQUIRE(::write(wend.get(), "test-posix-dup", 14) != -1); char buf1[15]; BOOST_REQUIRE_EQUAL(::read(rend.get(), buf1, sizeof(buf1)), 14); buf1[14] = '\0'; BOOST_REQUIRE(std::strcmp(buf1, "test-posix-dup") == 0); BOOST_REQUIRE(::write(fh1.get(), "test-posix-dup", 14) != -1); char buf2[15]; BOOST_REQUIRE_EQUAL(::read(rend.get(), buf2, sizeof(buf2)), 14); buf2[14] = '\0'; BOOST_REQUIRE(std::strcmp(buf2, "test-posix-dup") == 0); }
Match::Match(const char *start_of_array, size_t array_size, size_t match_start_offset, size_t match_end_offset, long long line_number) { auto line_ending = "\n"; // Find the start of the line. std::reverse_iterator<const char*> rstart(start_of_array+match_start_offset); std::reverse_iterator<const char*> rend(start_of_array); auto line_start_rit = std::find(rstart, rend, line_ending[0]); const char *line_start; if(line_start_rit == rend) { // The line has no starting '\n', so it must be the first line. line_start = start_of_array; } else { // The line had a starting '\n', clip it off. line_start = line_start_rit.base(); } // Find the end of the matched line. auto line_end = std::find(start_of_array+match_start_offset, start_of_array+array_size, line_ending[0]); // Form the match substrings. m_pre_match = std::string(line_start, start_of_array+match_start_offset); m_match = std::string(start_of_array+match_start_offset, start_of_array+match_end_offset); m_post_match = std::string(start_of_array+match_start_offset+(match_end_offset-match_start_offset), line_end); m_line_number = line_number; }
/** Finalize Threads. * The threads are finalized. * This operation is carried out unlocked. Lock it from the outside if needed. * This is done because it is likely that this will be chained with other * actions that require locking, thus you can lock the whole operation. * @param finalizer thread finalizer to use to finalize the threads */ void ThreadList::finalize(ThreadFinalizer *finalizer) { bool error = false; Exception me("One or more threads failed to finalize"); for (reverse_iterator i = rbegin(); i != rend(); ++i) { try { (*i)->finalize(); } catch (CannotFinalizeThreadException &e) { error = true; me.append("AspectIniFin called Thread[%s]::finalize() which failed", (*i)->name()); me.append(e); } catch (Exception &e) { error = true; me.append("AspectIniFin called Thread[%s]::finalize() which failed", (*i)->name()); me.append(e); } catch (...) { error = true; me.append("Thread[%s]::finalize() threw unsupported exception", (*i)->name()); } try { finalizer->finalize(*i); } catch (CannotFinalizeThreadException &e) { error = true; me.append("Could not finalize thread '%s' in list '%s'", (*i)->name(), __name); me.append(e); } } if ( error ) { throw me; } }
CandidateSet::iterator CandidateSet::getCandidateTree(string topology) { for (CandidateSet::reverse_iterator rit = rbegin(); rit != rend(); rit++) { if (rit->second.topology == topology) return --(rit.base()); } return end(); }
std::vector<CreaturePtr> Map::getSpectatorsInRangeEx(const Position& centerPos, bool multiFloor, int minXRange, int maxXRange, int minYRange, int maxYRange) { int minZRange = 0; int maxZRange = 0; std::vector<CreaturePtr> creatures; if(multiFloor) { minZRange = 0; maxZRange = Otc::MAX_Z; } //TODO: optimize //TODO: get creatures from other floors corretly //TODO: delivery creatures in distance order for(int iz=-minZRange; iz<=maxZRange; ++iz) { for(int iy=-minYRange; iy<=maxYRange; ++iy) { for(int ix=-minXRange; ix<=maxXRange; ++ix) { TilePtr tile = getTile(centerPos.translated(ix,iy,iz)); if(!tile) continue; auto tileCreatures = tile->getCreatures(); creatures.insert(creatures.end(), tileCreatures.rbegin(), tileCreatures.rend()); } } } return creatures; }
void Scene::cleanup() { auto toBeDestroyed = findGameObjects([](GameObject & go){return (go.toBeDestroyed_ == true);}); for(auto it = toBeDestroyed.rbegin(); it != toBeDestroyed.rend(); it++) { auto* go = *it; go->setParent(nullptr); auto rootIt = std::find(root_->children_.begin(), root_->children_.end(), go); auto gameObjectsIt = std::find(gameObjects_.begin(), gameObjects_.end(), go); //the scene graph must contain this object assert(rootIt != root_->children_.end()); //the list of all gameobjects must contain this object assert(gameObjectsIt != gameObjects_.end()); //remove from scene graph root_->children_.erase(rootIt); //remove from all gameobjects gameObjects_.erase(gameObjectsIt); delete go; } }
DecodeOrderSampleMap::reverse_iterator DecodeOrderSampleMap::reverseFindSampleWithDecodeKey(const KeyType& key) { DecodeOrderSampleMap::iterator found = findSampleWithDecodeKey(key); if (found == end()) return rend(); return --reverse_iterator(found); }
inline T foldr(Cont&& cont, BinaryFunc&& func, T starting) { auto first = rbegin(std::forward<Cont>(cont)); auto last = rend(std::forward<Cont>(cont)); for(; first != last; ++first) starting = func(*first, starting); return starting; }
DecodeOrderSampleMap::reverse_iterator DecodeOrderSampleMap::findSyncSamplePriorToPresentationTime(const MediaTime& time, const MediaTime& threshold) { PresentationOrderSampleMap::reverse_iterator reverseCurrentSamplePTS = m_presentationOrder.reverseFindSampleBeforePresentationTime(time); if (reverseCurrentSamplePTS == m_presentationOrder.rend()) return rend(); const RefPtr<MediaSample>& sample = reverseCurrentSamplePTS->second; reverse_iterator reverseCurrentSampleDTS = reverseFindSampleWithDecodeKey(KeyType(sample->decodeTime(), sample->presentationTime())); reverse_iterator foundSample = findSyncSamplePriorToDecodeIterator(reverseCurrentSampleDTS); if (foundSample == rend()) return rend(); if (foundSample->second->presentationTime() < time - threshold) return rend(); return foundSample; }
void Messages::display_messages(WINDOW *const ipk_target, int const left, int const top, int const right, int const bottom) { if (!size()) { return; } int const maxlength = right - left; int line = bottom; for (int i = size() - 1; i >= 0; --i) { if (line < top) { break; } const game_message &m = player_messages.impl_->messages[i]; const nc_color col = m.get_color(player_messages.impl_->curmes); const auto folded_strings = foldstring(m.get_with_count(), maxlength); const auto folded_rend = folded_strings.rend(); for( auto string_iter = folded_strings.rbegin(); string_iter != folded_rend && line >= top; ++string_iter, line-- ) { mvwprintz(ipk_target, line, left, col, "%s", string_iter->c_str()); } } player_messages.impl_->curmes = calendar::turn.get_turn(); }
std::vector<std::string> getProcArgs(int pid, size_t argmax) { auto raw_args = getProcRawArgs(pid, argmax); std::vector<std::string> args; bool collect = false; // Iterate from the back until we stop seeing environment vars // Then start pushing args (in reverse order) onto a vector. // We trim the args of leading/trailing whitespace to make // analysis easier. for (auto itr = raw_args.rbegin(); itr < raw_args.rend(); ++itr) { if (collect) { std::string arg = *itr; boost::algorithm::trim(arg); args.push_back(arg); } else { size_t idx = itr->find_first_of("="); if (idx == std::string::npos) { collect = true; } } } // We pushed them on backwards, so we need to fix that. std::reverse(args.begin(), args.end()); return args; }
ZOrderedCells::ReverseIterator ZOrderedCells::findLast(const CellSet & cells) { ReverseIterator it = rbegin(); for(; it != rend(); ++it) if(cells.contains(*it)) break; return it; }
PositionVector PositionVector::reverse() const { PositionVector ret; for (const_reverse_iterator i = rbegin(); i != rend(); i++) { ret.push_back(*i); } return ret; }
static std::vector<int64_t> computeLinearStride(const Tensor & tensor) { // computes the stride as if tensor were contigous auto sizes = tensor.sizes(); std::vector<int64_t> stride(tensor.dim()); stride[tensor.dim() - 1] = 1; std::partial_sum(sizes.rbegin(), sizes.rend() - 1, stride.rbegin() + 1, std::multiplies<int64_t>()); return stride; }
void CSVRow::erase(CSVRecordMap::reverse_iterator iter) { if (iter!=rend()) { if (iter->second) { delete iter->second; } _values.erase(--(iter.base())); } }
//Remove gelps from this pickobjects. void MGPickObjects::remove(const MGGelPositions& gelps){ reverse_iterator i=rbegin(), iend=rend(); for(; i!=iend;){ MGPickObject& po=**i++; iterator ifoward=i.base(); if(gelps.includes(po.gel())) erase(ifoward); } }
array() { iterator i(begin()); try { for (; i != end(); ++i) new (i) value_type(); } catch (...) { for (reverse_iterator j(i); j != rend(); ++j) (*j).~value_type(); throw; } }
void CandidateSet::initParentTrees() { if (parentTrees.empty()) { int count = Params::getInstance().popSize; for (reverse_iterator i = rbegin(); i != rend() && count > 0; i++, count--) { parentTrees.push(i->second.tree); //cout << i->first << endl; } } }
vector<double> CandidateSet::getBestScores(int numBestScore) { if (numBestScore == 0) numBestScore = size(); vector<double> res; for (reverse_iterator rit = rbegin(); rit != rend() && numBestScore > 0; rit++, numBestScore--) { res.push_back(rit->first); } return res; }
/** Cancel finalization on all threads. */ void ThreadList::cancel_finalize() { MutexLocker lock(__finalize_mutex); for (reverse_iterator i = rbegin(); i != rend(); ++i) { (*i)->cancel_finalize(); } }
PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: rbegin() { if (empty()) return rend(); return --end(); }
//Remove objects of type from this pickobjects. void MGPickObjects::remove(const MGAbstractGels& types){ reverse_iterator i=rbegin(), ie=rend(); for(; i!=ie;){ if((**i).gel()->type_is(types)){ m_PickObjects.erase((++i).base()); }else i++; } }
uint32 RangeSet::getPrev(uint32 v) const { for (const_reverse_iterator it = rbegin(); it != rend(); ++it) { if (lower(it) < v) return min(v - 1, upper(it)); } return RangeSetAbsent; }