本文整理汇总了C++中std::vector::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::pop_back方法的具体用法?C++ vector::pop_back怎么用?C++ vector::pop_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::vector
的用法示例。
在下文中一共展示了vector::pop_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: subsets
std::vector<std::vector<T> > subsets(std::vector<T> set,std::size_t k){
if(set.size() == k){
return {set};
}
if(k== 1){
std::vector<std::vector<T> > result;
for(auto const& point: set){
result.push_back({point});
}
return result;
}
T point = set.back();
set.pop_back();
auto km1subsets = subsets(set,k-1);
auto result = subsets(set,k);
for(auto & s: km1subsets){
s.push_back(point);
result.push_back(std::move(s));
}
return result;
}
示例2: lock
thread_pool_executor(uint32_t aThreadCount) :
mWorkerThreads(new std::thread[aThreadCount]),
mThreadCount(aThreadCount),
mExit(false)
{
const auto threadFn = [this]() {
while(! mExit) {
std::unique_lock<std::mutex> lock(mTasksLock);
mTaskAdded.wait(lock);
if(! mTasks.empty()) {
std::function<void()> task = mTasks.back();
mTasks.pop_back();
lock.unlock();
task();
}
}
};
for(uint32_t i = 0; i < aThreadCount; ++i) mWorkerThreads[i] = std::thread(threadFn);
}
示例3: FindAndSortUnits
/**
** Find all units to draw in viewport.
**
** @param vp Viewport to be drawn.
** @param table Table of units to return in sorted order
**
*/
int FindAndSortUnits(const CViewport &vp, std::vector<CUnit *> &table)
{
// Select all units touching the viewpoint.
const Vec2i offset(1, 1);
const Vec2i vpSize(vp.MapWidth, vp.MapHeight);
const Vec2i minPos = vp.MapPos - offset;
const Vec2i maxPos = vp.MapPos + vpSize + offset;
Select(minPos, maxPos, table);
size_t n = table.size();
for (size_t i = 0; i < table.size(); ++i) {
if (!table[i]->IsVisibleInViewport(vp)) {
table[i--] = table[--n];
table.pop_back();
}
}
Assert(n == table.size());
std::sort(table.begin(), table.begin() + n, DrawLevelCompare);
return n;
}
示例4: appendBindingList
void NamingContextHelper::appendBindingList(CosNaming::BindingList_var& bList, std::vector<ObjectPath> pathList, ObjectInfoList& objects)
{
for (CORBA::ULong i = 0; i < bList->length(); ++i) {
ObjectInfo info;
info.id_ = bList[i].binding_name[0].id;
info.kind_ = bList[i].binding_name[0].kind;
info.hostAddress_ = host_;
info.portNo_ = port_;
ObjectPath path(info.id_, info.kind_);
pathList.push_back(path);
CORBA::Object_ptr obj = findObjectSub(pathList);
info.isAlive_ = isObjectAlive(obj);
info.ior_ = orb->object_to_string(obj);
copy(pathList.begin(), pathList.end(), std::back_inserter(info.fullPath_));
pathList.pop_back();
CORBA::release(obj);
objects.push_back(info);
}
}
示例5: get_group
gl_sframe grouped_sframe::get_group(std::vector<flexible_type> key) {
if(!m_inited) {
log_and_throw("The 'group' operation needs to occur before getting a "
"group!");
}
//TODO: This is a HUGE hack. From the Python side, a list of ints is turned
//in to a list of floats unless there's a None in it. We add a None so this
//doesn't happen and take it away to look up the group. We'll actually fix
//the problem soon.
if((key.size() > 1) && (key.back().get_type() == flex_type_enum::UNDEFINED)) {
key.pop_back();
}
auto ret = m_key2range.find(key);
if(ret == m_key2range.end()) {
log_and_throw("Group not found!");
}
size_t range_dir_idx = ret->second;
return this->get_group_by_index(range_dir_idx);
}
示例6: while
void RegionalTerrain_3r::TestAndSwapEdges(std::vector<QuadEdge::Edge*>& edges,
const Point_3r& sample) {
while (!edges.empty()) {
QuadEdge::Edge *e1 = edges.back();
edges.pop_back();
QuadEdge::Vertex *v1 = e1->Org(), *v2 = e1->Dest();
QuadEdge::Edge *e2 = e1->Lnext();
QuadEdge::Edge *e3 = e1->Lprev();
QuadEdge::Vertex *v3 = e2->Dest();
QuadEdge::Edge *e4 = e1->Rnext();
QuadEdge::Edge *e5 = e1->Rprev();
if (Predicate::InCircle(*v1->pos, *v2->pos, *v3->pos, sample) > 0) {
QuadEdge::Face *left = e1->Left();
KillFaceEdge(e1);
MakeFaceEdge(left, e2->Dest(), e5->Dest());
edges.push_back(e2->Sym());
edges.push_back(e3->Sym());
}
}
}
示例7: dfs
void dfs(int depth,int last,int left){
if(left == 1 ){
int size = ans.size();
long double temp = 1.0;
for(int i=0;i<size;i++){
temp *= (long double)pow(prime[i],ans[i]-1);
}
if( temp < result )
result = temp;
}
else {
int len = nd[left].size();
for(int i=0;i<len;i++){
if(nd[left][i] <=last ) {
ans.push_back(nd[left][i]);
dfs(depth+1,nd[left][i],left / nd[left][i]);
ans.pop_back();
}
}
}
}
示例8: getInstance
T* getInstance()
{
if (pool.empty())
{
// we don't care about locking here since it is not dangerous to get a false answer
return new T();
}
T* impl;
{
MutexLock lock(poolMutex);
if (pool.empty())
return new T();
impl = pool.back();
pool.pop_back();
}
return impl;
}
示例9: requestShutdown
void RequestWorkloadStats::requestShutdown() {
if (m_s.empty()) return;
end(m_php);
assertx(m_s.back() == State::InRequest);
m_s.pop_back();
assertx(m_s.empty());
const auto php = m_php.acc;
const auto interp = m_interp.acc;
s_interpNanos->addValue(interp);
s_requestNanos->addValue(php);
if (php > 0) {
s_interpVMRatio->addValue(interp * 10000 / php);
}
// Log state change counts.
s_trans->addValue(m_transitionCounts[State::InTrans]);
s_interps->addValue(m_transitionCounts[State::InInterp]);
}
示例10: ProcessStack
/**
* Try to merge region with same level
* @param nextLevel Level used to limit search
* @param pixel_x X-coord of the base of the merged region
* @param pixel_y Y-coord of the base of the merged region
*/
void MSERExtractor::ProcessStack( const int nextLevel , const int pixel_x , const int pixel_y , std::vector<MSERRegion * > & regionStack ) const
{
do
{
MSERRegion * top = regionStack.back();
regionStack.pop_back();
if (nextLevel < regionStack.back()->m_level )
{
regionStack.push_back( new MSERRegion( nextLevel , pixel_x , pixel_y ) );
regionStack.back()->MergeRegion( top );
return;
}
regionStack.back()->MergeRegion( top );
}
while (nextLevel > regionStack.back()->m_level);
}
示例11: decrement
// If board[w] becomes T() again, we need to update who
inline void decrement(size_type w)
{
assert(w < board.size());
if (board[w] == T()) {
who.push_back(w);
//assert(std::set<size_type>(who.begin(),who.end()).size() == who.size());
}
-- board[w];
// To make sure we keep the uniqueness invariant,
// might be costly if not very sparse?
if (board[w] == T()) {
size_type i = 0;
while (who[i] != w)
++i;
std::swap(who[i], who[who.size()-1]);
who.pop_back();
}
}
示例12: insertSegment
void LLKeywords::insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor )
{
LLTextSegmentPtr last = seg_list.back();
S32 new_seg_end = new_segment->getEnd();
llassert(new_seg_end <= text_len);
if( new_segment->getStart() == last->getStart() )
{
seg_list.pop_back();
}
else
{
last->setEnd( new_segment->getStart() );
}
seg_list.push_back( new_segment );
if( new_seg_end < text_len )
{
seg_list.push_back( new LLTextSegment( defaultColor, new_seg_end, text_len ) );
}
}
示例13: popControlStack
void popControlStack(bool isElse = false)
{
VALIDATE_UNLESS("stack was not empty at end of control structure: ",stack.size() > controlStack.back().outerStackSize);
if(isElse && controlStack.back().type == ControlContext::Type::ifThen)
{
controlStack.back().type = ControlContext::Type::ifElse;
controlStack.back().isReachable = true;
}
else
{
VALIDATE_UNLESS("else only allowed in if context: ",isElse);
const ResultType resultType = controlStack.back().resultType;
if(controlStack.back().type == ControlContext::Type::ifThen && resultType != ResultType::none)
{
throw ValidationException("else-less if may not yield a result");
}
controlStack.pop_back();
if(controlStack.size()) { pushOperand(resultType); }
}
}
示例14: ProcessOrderAfterRecursion
void LightWeightStaticOrderMCS::ProcessOrderAfterRecursion(std::vector<int> &vVertexOrder, std::vector<int> &P, std::vector<int> &vColors, int const chosenVertex)
{
if (chosenVertex == -1) return;
#if 1
vVertexOrder.erase(find(vVertexOrder.begin(), vVertexOrder.end(), chosenVertex));
#else
// try searching from end, might be faster in general...
size_t indexAfterVertex(0);
for (indexAfterVertex = vVertexOrder.size(); indexAfterVertex >= 1; indexAfterVertex--) {
if (vVertexOrder[indexAfterVertex-1] == chosenVertex) {
break;
}
}
for (; indexAfterVertex < vVertexOrder.size(); indexAfterVertex++) {
vVertexOrder[indexAfterVertex-1] = vVertexOrder[indexAfterVertex];
}
vVertexOrder.pop_back();
#endif // 0
R.pop_back();
}
示例15: prev_vector_by_left_first
bool prev_vector_by_left_first( std::vector< T >& iv,
T fst, T lst ) {
std::vector< T > v_tmp;
while ( !iv.empty() ) {
if ( iv.back() > fst ) {
iv.back()--;
while ( !v_tmp.empty() ) {
v_tmp.pop_back();
iv.push_back( lst );
}
return true;
}
v_tmp.push_back( iv.back() );
iv.pop_back();
}
while ( !v_tmp.empty() ) {
iv.push_back( v_tmp.back() );
v_tmp.pop_back();
}
return false;
}