本文整理汇总了C++中Vec::back方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec::back方法的具体用法?C++ Vec::back怎么用?C++ Vec::back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec
的用法示例。
在下文中一共展示了Vec::back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pop
T pop() {
if (front->empty()) {
js::Reverse(back->begin(), back->end());
Vec *tmp = front;
front = back;
back = tmp;
}
T item = front->back();
front->popBack();
return item;
}
示例2: update_in_a_cycle
void Instruction::update_in_a_cycle() {
++Instruction::cur_op_id;
Vec<std::pair<Instruction *,unsigned>> stack;
stack.emplace_back( this, 0 );
while ( true ) {
std::pair<Instruction *,unsigned> t = stack.back();
// instruction
if ( t.first->op_id == Instruction::cur_op_id ) {
stack.pop_back();
if ( t.first->num_in_dfs_stack >= 0 )
for( unsigned j = t.first->num_in_dfs_stack; j < stack.size(); ++j )
stack[ j ].first->in_a_cycle = true;
} else {
t.first->op_id = Instruction::cur_op_id;
t.first->num_in_dfs_stack = stack.size() - 1;
}
// next
while ( stack.back().second >= stack.back().first->next.size() ) {
stack.back().first->num_in_dfs_stack = - 1;
stack.pop_back();
if ( stack.empty() )
return;
}
stack.emplace_back( stack.back().first->next[ stack.back().second++ ].inst, 0 );
}
}
示例3: push_not_rec
static void push_not_rec( BoolOpSeq &res, const BoolOpSeq &a, const Vec<int> &ind ) {
if ( ind.size() == a.or_seq.size() ) {
Vec<BoolOpSeq::Item> tmp;
for( int i = 0; i < ind.size(); ++i )
tmp << BoolOpSeq::Item{ a.or_seq[ i ][ ind[ i ] ].expr, not a.or_seq[ i ][ ind[ i ] ].pos };
res.or_seq << tmp;
return;
}
Vec<int> tmp = ind; tmp << 0;
for( int i = 0; i < a.or_seq[ ind.size() ].size(); ++i ) {
tmp.back() = i;
push_not_rec( res, a, tmp );
}
}
示例4: strategy2
void strategy2()
{
int numElems;
cin >> numElems;
Vec plants;
Killers killers; // toxicity, days to live
int maxDays(-1);
//
// Read in all the plant values
//
for (int ii = 0; ii < numElems; ii++)
{
plants.push_back(0);
cin >> plants.back();
}
killers.push_front(make_pair(plants[0], -1));
for (int ii = 1; ii < numElems; ii++)
{
int myTTL(1);
while (!killers.empty())
{
//
// Compare this plant's toxicity to the previous known killer
//
int thisTox(plants[ii]);
int killerTox(killers.front().first);
cout << "thisTox " << thisTox << " killerTox " << killerTox << endl;
// If we're stronger than newest killer, remove it from the kill
// list. Our TTL is the killers TTL + 1
if (thisTox < killerTox)
{
myTTL = max(killers.front().second + 1, myTTL);
cout << "myTTL " << myTTL << endl;
killers.pop_front();
// maxDays = max(maxDays, myTTL);
// cout << "maxDays is now " << maxDays << endl;
}
else
{
// We will die in 1 day, don't need to run through the
// rest of the kill list
// maxDays = max(maxDays, 0);
break;
}
dumpKillers(killers);
}
if (killers.empty())
{
// The newest plant is stronger than all others,
// it's the sole occupant of the kill list
myTTL = -1;
}
killers.push_front(make_pair(plants[ii], myTTL));
maxDays = max(maxDays, myTTL);
dumpKillers(killers);
}
maxDays = max(maxDays, 0);
cout << maxDays << endl;
}
示例5: append
void append(uint32_t pos)
{
assert(v_.empty() ? pos == 0 : v_.back() < pos);
v_.push_back(pos);
}