首页 > 解决方案 > C++ 中的双端队列

问题描述

每次调用这个函数,我都会得到一个 Segmentation Fault。我发现 pop_front() 函数没有按预期运行。我尝试用擦除功能替换它,但它没有解决问题。我想问为什么它不起作用以及我应该如何解决它。

void front(deque <pair<int64_t, int64_t>> p, int64_t o, int64_t t, int64_t per)
{
    int64_t i=0;
    while(i<per) {
        if(p.front().second > per) {
            i = per;
            p.front().second =- per;
        }
        else {
            i = p.front().second;
            p.pop_front();
        }
    }
    p.push_front(make_pair(t, o+per));
}

标签: c++dequestd-pair

解决方案


推荐阅读