本文整理汇总了C++中rbegin函数的典型用法代码示例。如果您正苦于以下问题:C++ rbegin函数的具体用法?C++ rbegin怎么用?C++ rbegin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rbegin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reservations_in_interval
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));
}
示例2: QcBuffer
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//! 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;
}
示例3: getNewsFeed
/** Retrieve the 10 most recent tweet ids in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user herself. Tweets must be ordered from most recent to least recent. */
std::vector<int> getNewsFeed(int u) {
std::vector<int> rslt;
auto feeds = m_tweets[u];
for (auto rit = feeds.rbegin();
rit != feeds.rend() && rit - feeds.rbegin() < 10;
++rit) {
rslt.push_back(rit->first);
}
return rslt;
}
示例4: lowestCommonAncestor
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q)
{
auto pathToP = pathToElem(root, p);
auto pathToQ = pathToElem(root, q);
size_t i = 0;
for (i = 0; i != std::min(pathToQ.size(), pathToP.size()); i++)
{
if (*(pathToQ.rbegin() + i) != *(pathToP.rbegin() + i)) break;
}
return *(pathToQ.rbegin() + i - 1);
}
示例5: TEST
TEST(WordCountOpenMPTest, FileParAndSeqTest)
{
pair<const char*, size_t> text = loadTextFromFile("book.txt");
auto counted1 = countWords(text.first, text.second);
auto flipped1 = flipMap<string, int>(counted1);
auto counted2 = countWordsOpenMP(text.first, text.second, defaultThreadCount);
auto flipped2 = flipMap<string, int>(counted2);
ASSERT_TRUE(std::equal(flipped1.rbegin(), flipped1.rend(), flipped2.rbegin()));
}
示例6: rend
PresentationOrderSampleMap::iterator_range PresentationOrderSampleMap::findSamplesWithinPresentationRangeFromEnd(const MediaTime& beginTime, const MediaTime& endTime)
{
reverse_iterator rangeEnd = std::find_if(rbegin(), rend(), [&beginTime] (PresentationOrderSampleMap::MapType::value_type value) {
return value.second->presentationTime() <= beginTime;
});
reverse_iterator rangeStart = std::find_if(rbegin(), rangeEnd, [&endTime] (PresentationOrderSampleMap::MapType::value_type value) {
return value.second->presentationTime() <= endTime;
});
return iterator_range(rangeEnd.base(), rangeStart.base());
}
示例7: GetLength
position_type GetLength (void) const
{
if(! m_vRanges.empty()) {
position_type From = begin()->GetFrom();
return rbegin()->GetToOpen() - From;
} else return 0;
}
示例8: find
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;
}/*}}}*/
示例9: foldr
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;
}
示例10: getCandidateTree
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();
}
示例11: findGameObjects
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;
}
}
示例12: GetColor
rColor rGradient::GetColor(float where) {
#ifndef DEDICATED
if(empty()) return rColor();
if(begin()->first >= where) return begin()->second;
iterator upper, lower;
iterator i=begin();
iterator j=begin();
++j;
bool finished = false;
for(; j!=end(); ++i, ++j) {
if(j->first >= where) {
lower = i;
upper = j;
finished = true;
break;
}
}
if (!finished) return rbegin()->second;
float diff = upper->first - lower->first;
float pos = where - lower->first;
rColor &c1 = lower->second;
rColor &c2 = upper->second;
float r = c1.r_*(diff-pos)/diff + c2.r_*pos/diff;
float g = c1.g_*(diff-pos)/diff + c2.g_*pos/diff;
float b = c1.b_*(diff-pos)/diff + c2.b_*pos/diff;
float a = c1.a_*(diff-pos)/diff + c2.a_*pos/diff;
return rColor(r,g,b,a);
#else
return rColor(0.,0.,0.,0.);
#endif
}
示例13: testReadUntil
inline void testReadUntil(const char* format)
{
TemporaryData data{format};
brion::SpikeReport reportWrite(brion::URI(data.tmpFileName),
brion::MODE_WRITE);
reportWrite.write(data.spikes);
reportWrite.close();
brion::SpikeReport reportRead(brion::URI(data.tmpFileName),
brion::MODE_READ);
auto spikes = reportRead.readUntil(0.15).get();
BOOST_CHECK_EQUAL(spikes.size(), 1);
BOOST_CHECK(reportRead.getCurrentTime() >= 0.15f);
spikes = reportRead.readUntil(0.3).get();
BOOST_CHECK_EQUAL(spikes.size(), 2);
BOOST_CHECK(reportRead.getCurrentTime() >= 0.3f);
BOOST_CHECK(spikes.rbegin()->first < 0.3);
BOOST_CHECK_EQUAL(reportRead.getState(), brion::SpikeReport::State::ok);
spikes = reportRead.read(brion::UNDEFINED_TIMESTAMP).get();
BOOST_CHECK_EQUAL(spikes.size(), 2);
BOOST_CHECK_EQUAL(reportRead.getCurrentTime(), brion::UNDEFINED_TIMESTAMP);
BOOST_CHECK_EQUAL(reportRead.getState(), brion::SpikeReport::State::ended);
}
示例14: _transpose
types::ndarray<T,N> _transpose(types::ndarray<T,N> const & a, long const l[N])
{
auto shape = a.shape;
types::array<long, N> shp;
for(unsigned long i=0; i<N; ++i)
shp[i] = shape[l[i]];
types::ndarray<T,N> new_array(shp, __builtin__::None);
types::array<long, N> new_strides;
new_strides[N-1] = 1;
std::transform(new_strides.rbegin(), new_strides.rend() -1, shp.rbegin(), new_strides.rbegin() + 1, std::multiplies<long>());
types::array<long, N> old_strides;
old_strides[N-1] = 1;
std::transform(old_strides.rbegin(), old_strides.rend() -1, shape.rbegin(), old_strides.rbegin() + 1, std::multiplies<long>());
auto iter = a.buffer,
iter_end = a.buffer + a.size();
for(long i=0; iter!=iter_end; ++iter, ++i) {
long offset = 0;
for(unsigned long s=0; s<N; s++)
offset += ((i/old_strides[l[s]]) % shape[l[s]])*new_strides[s];
new_array.buffer[offset] = *iter;
}
return new_array;
}
示例15: getTile
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;
}