本文整理汇总了C++中std::deque::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::pop_back方法的具体用法?C++ deque::pop_back怎么用?C++ deque::pop_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::pop_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluate_unary_operator
bool evaluate_unary_operator(const object& operator_object,bool expand = true)
{
object result, arg;
bool eval = true;
if(optic_stack.size())
{
eval = evaluate_top();
if(eval)
{
arg = optic_stack.back();
optic_stack.pop_back();
if(arg.type == ARRAY && expand)
{
object new_array = mem_alloc(ARRAY);
for(int i = 0; i < arg.data.array->size(); ++i)
{
// optic_stack.push_back(mem_copy(arg.data.array->at(i)));
optic_stack.push_back(arg.data.array->at(i));
optic_stack.push_back(operator_object);
if(evaluate_top())
{
new_array.data.array->push_back(mem_copy(optic_stack.back()));
optic_stack.pop_back();
}
}
result = new_array;
}
else
{
operator_object.data.unary_operator_func(result, arg);
}
// mem_free(arg);
optic_stack.push_back(result);
return true;
}
}
else
{
eval = false;
}
if(!eval)
{
mem_free(arg);
out() << "Missing argument for unary operator" << std::endl;
clear_stack();
return false;
}
}
示例2: unwindTokens
static void unwindTokens(std::deque<int>& queue, int tok) {
assert(!queue.empty() && "Token stack is empty!");
while (queue.back() != tok) {
queue.pop_back();
assert(!queue.empty() && "Token stack is empty!");
}
queue.pop_back();
}
示例3: push
void push(int x) {
while(!stackB.empty()){
stackA.push_back(stackB.back());
stackB.pop_back();
}
stackA.push_back(x);
while(!stackA.empty()){
stackB.push_back(stackA.back());
stackA.pop_back();
}
}
示例4: main
int main(){
//freopen("sun.in","r",stdin);
//freopen("sun.out","w",stdout);
scanf("%d",&n);
scanf("%s",s);
for (int i = 0; i < n; ++i){
q.push_back(s[i]);
}
while(!q.empty()){
if(q.front()<q.back()){
putchar(q.front());
q.pop_front();
}else if(q.front()>q.back()){
putchar(q.back());
q.pop_back();
}else{
if(q.size()==1){
putchar(q.front());
break;
}
while(q.front()==q.back() && q.size()!=1){
lq.push_back(q.front());
rq.push_back(q.front());
if(q.front()>q.back()){
while(!rq.empty()){
putchar(rq.front());
rq.pop_front();
}
putchar(q.back());
q.pop_back();
while(!lq.empty()){
q.push_front(lq.back());
lq.pop_back();
}
}else{
while(!rq.empty()){
putchar(rq.front());
rq.pop_front();
}
putchar(q.back());
q.pop_front();
while(!lq.empty()){
q.push_back(lq.back());
lq.pop_back();
}
}
}
}
}
putchar('\n');
return 0;
}
示例5: align_back
static void align_back(const std::deque<timestamp_t> &reference,
std::deque<timestamp_t> &target,
std::deque<vec3_t> &data) {
const auto back = reference.back();
while (true) {
if (target.back() > back) {
target.pop_back();
data.pop_back();
} else {
break;
}
}
}
示例6: return
JNIEXPORT jchar JNICALL
Java_link_kjr_SimpleTerminal_MainActivity_get_1char__(JNIEnv *env, jclass type) {
char f=buffer.back();
buffer.pop_back();
return (jchar) f;
}
示例7: qread
int qread() {
if (m_deq.empty())
return super_t::read();
unsigned char c = m_deq.back();
m_deq.pop_back();
return c;
}
示例8: main
int main() {
while (~scanf("%d %d", &n, &m)) {
init(n);
for (int i = 1; i <= n; ++i) {
scanf("%I64d", s + i);
s[i] += s[i - 1];
}
dp[1] = s[1] * s[1] + m;
q.push_back(0);
for (int i = 1; i <= n; ++i) {
while (q.size() >= 2 && Up(q[1], q.front()) <= s[i] * Down(q[1], q.front())) {
// printf(" %d\n", q[1]);
// printf("--- %I64d %d\n", dp[i], q.size());
q.pop_front();
}
if (!q.empty())
Dp(i, q.front());
// printf("%I64d %d\n", dp[i], q.size());
while (q.size() >= 2 /*&& 1, printf("--- %I64d %d\n *** %I64d %I64d\n", dp[i], q.back(), Up(i, q.back()) * Down(q.back(), q[q.size() - 2]), Up(q.back(), q[q.size() - 2]) * Down(i, q.back())) */&& Up(i, q.back()) * Down(q.back(), q[q.size() - 2]) <= Up(q.back(), q[q.size() - 2]) * Down(i, q.back())) {
// ;
// printf(" %d\n", q[1]);
q.pop_back();
}
q.push_back(i);
// printf(" %d\n", q.size());
}
printf("%I64d\n", dp[n]);
}
}
示例9: dijkstra_LIFO_thread
void dijkstra_LIFO_thread(CSRGraph *g, int *dist, std::deque<int> &deq, int threadNum, int *onstack, std::mutex *dist_locks)
{
while(!deq.empty())
{
queue_lock.lock();
if(deq.empty()){
queue_lock.unlock();
break;
}
int u = deq.back();
deq.pop_back();
printf("Popped\n");
for(int i=0; i< deq.size();i++){
printf(" %d", deq[i]);
}
printf("\n");
onstack[u]=0;
int udist = dist[u];
queue_lock.unlock();
std::vector<int> neighbors = CSRGraph_getNeighbors(g, u);
int neighbor;
for(neighbor=0;neighbor < neighbors.size(); neighbor++)
{
int v = neighbors[neighbor];
int uvdist = CSRGraph_getDistance(g, u, v);
int alt = udist + uvdist;
dist_locks[v].lock();
if(alt < dist[v])
{
dist[v] = alt;
dist_locks[v].unlock();
queue_lock.lock();
if(onstack[v] == 0)
{
deq.push_back(v);
printf("Pushed\n");
for(int i=0; i< deq.size();i++){
printf(" %d", deq[i]);
}
printf("\n");
onstack[v]=1;
}
queue_lock.unlock();
}
else
{
dist_locks[v].unlock();
}
}
}
//printf("Thread %d ended.\n", threadNum);
}
示例10: dequeBack
value_type dequeBack()
{
libmaus2::parallel::ScopePosixSpinLock llock(lock);
value_type const v = Q.back();
Q.pop_back();
return v;
}
示例11: maximumContiguousSum
int maximumContiguousSum(std::deque<int> &numbers) {
int max = 0;
std::deque<int>::iterator boundary;
std::deque<int>::iterator adder;
while (numbers.size() > 0) {
for (boundary = numbers.end(); boundary != numbers.begin(); boundary--) {
int testSum = 0;
for (adder = numbers.begin(); adder != boundary; adder++) {
testSum += *adder;
}
if (testSum > max) { max = testSum; }
}
for (boundary = numbers.begin(); boundary != numbers.end(); boundary++) {
int testSum = 0;
for (adder = boundary; adder != numbers.end(); adder++) {
testSum += *adder;
}
if (testSum > max) { max = testSum; }
}
if (!numbers.empty()) { numbers.pop_back(); }
if (!numbers.empty()) { numbers.pop_front(); }
if (numbers.size() == 1) {
if (numbers.at(0) > max) { max = numbers.at(0); }
}
}
return max;
}
示例12: disambiguate
static inline void propagate_age_update(Cfg& conf, std::deque<Cfg>& tmpres, std::size_t dst) {
// here we propagate an age field update to all pointers that are equal
// and thus experience the update too => only for age updates of next fields
// split to find truly equal pointers
auto shape_split = disambiguate(*conf.shape, dst);
for (Shape* s : shape_split) {
tmpres.emplace_back(Cfg(conf, s));
Cfg& config = tmpres.back();
// pointer equal to dst => experiences age update too
for (std::size_t i = 0; i < s->size(); i++) {
if (i == dst) continue;
if (s->test(i, dst, EQ)) {
#if CAS_OVERAPPROXIMATE_AGE_PROPAGATION
// overapproximation: drop age relation of pointers that observe the age assignemnt
for (std::size_t j = 0; j < s->size(); j++)
for (bool b : {false, true})
config.ages->set(j, b, i, true, AgeRel::BOT);
#else
mk_next_age_equal(config, i, dst, true);
#endif
}
}
}
// the shape/ages from conf may no longer be valid => overwrite the shape/ages
conf.shape = std::move(tmpres.back().shape);
conf.ages = std::move(tmpres.back().ages);
tmpres.pop_back();
}
示例13: hier_pop_mat
void hier_pop_mat()
{
if (!matrix_stack.empty())
{
current_mat=matrix_stack.back();
matrix_stack.pop_back();
}
}
示例14: set
// set key and value
size_t set(const Key& k, const Value&& v) {
if( data_.count(k) ) return data_.size();
cache_.push_back(k);
while (!max_cache_.empty() && max_cache_.back() < k) max_cache_.pop_back();
max_cache_.push_back(k);
data_[k] = std::move(v);
return data_.size();
}
示例15: mouseDrag
void LineRenderingSampleApp::mouseDrag(MouseEvent event)
{
mMousePositions.push_front(vec3(event.getPos(), 0.0f));
if (mMousePositions.size() > mMaxMousePositions)
{
mMousePositions.pop_back();
}
}