c++ - 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));
}
解决方案
推荐阅读
- visual-studio - 是否可以从 Web 应用程序在浏览器中启动 Word 365 来编辑文档,无论用户是否拥有 Office 365 许可证?
- javascript - 将 KB 转换为 MB 和 GB
- google-cloud-platform - 为部署在 Google AI Platform 上的 AI 应用程序公开 API 端点
- google-apps-script - 计算标签中的所有电子邮件
- rest - 应该使用什么 REST 方法来实现简单的进程间通信?
- laravel - 保存到数据库后自动发送电子邮件
- javascript - 用于专有名称的 JS 正则表达式:如何在每个单词的开头强制使用大写字母?
- javascript - 如何禁用页面加载?
- serverless-framework - 在无服务器框架中找不到满足声明的有效选项
- nativescript - saveToFile 未将图像显示到图库中