本文整理汇总了C++中std::deque::emplace_front方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::emplace_front方法的具体用法?C++ deque::emplace_front怎么用?C++ deque::emplace_front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::emplace_front方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: command
void RedisAsyncClient::command(const std::string &cmd, std::deque<RedisBuffer> args,
std::function<void(RedisValue)> handler)
{
if(stateValid())
{
args.emplace_front(cmd);
pimpl->post(std::bind(&RedisClientImpl::doAsyncCommand, pimpl,
std::move(pimpl->makeCommand(args)), std::move(handler)));
}
}
示例2: addMutationCandidate
void addMutationCandidate(const Sample<value_t> & sample,
const contribution_t & contribution,
ValuatedRegionNode * viewCell) {
/*
* Insert new mutation candidates at the front because their mutation
* count is zero. Therefore, the array stays sorted.
*/
const bool useOrigin = (sample.getNumHits() < 2);
if(std::get<0>(contribution) > 0) {
const auto originPoint = useOrigin ? sample.getOrigin() :
sample.getBackwardTerminationPoint();
Node * originObject = useOrigin ? static_cast<Node *>(viewCell) :
sample.getBackwardResult();
const auto terminationPoint = sample.getForwardTerminationPoint();
if(originPoint.distanceSquared(terminationPoint) > 1.0e-3) {
mutationCandidates.emplace_front(originPoint,
originObject,
terminationPoint,
sample.getForwardResult());
}
}
if(std::get<1>(contribution) > 0) {
const auto originPoint = useOrigin ? sample.getOrigin() :
sample.getForwardTerminationPoint();
Node * originObject = useOrigin ? static_cast<Node *>(viewCell) :
sample.getForwardResult();
const auto terminationPoint = sample.getBackwardTerminationPoint();
if(originPoint.distanceSquared(terminationPoint) > 1.0e-3) {
mutationCandidates.emplace_front(originPoint,
originObject,
terminationPoint,
sample.getBackwardResult());
}
}
// Constant suggested in the article
const uint32_t maxNumMutationCandidates = 2000000;
while(mutationCandidates.size() > maxNumMutationCandidates) {
mutationCandidates.pop_back();
}
}
示例3: dispatcher_
result_type
traverse(std::conditional_t< reassmble, ast::expression &&, ast::expression const & > _input)
{ // if reassmble is true, then input is taken apart, then reassembled
assert(output_.empty());
if (_input.rest_.empty()) {
return dispatcher_(std::move(_input.first_));
} else if (_input.rest_.size() == 1) {
auto & operation_ = _input.rest_.back();
return dispatcher_(std::move(_input.first_),
operation_.operator_,
std::move(operation_.operand_));
} else {
//output_.reserve(_input.rest_.size() * 2 + 1); // total number of operators and operands
std::stack< aggregate_wrapper< lhs_op > > lhs_op_;
for (auto & operation_ : _input.rest_) {
size_type const precedence_ = ast::precedence(operation_.operator_);
while (!lhs_op_.empty()) {
lhs_op const & top_ = lhs_op_.top();
if (ast::precedence(top_.operator_) < precedence_) {
break;
}
output_.emplace_back(top_.lhs_, top_.operator_, output_.size());
lhs_op_.pop();
}
lhs_op_.emplace(output_.size(), operation_.operator_);
output_.emplace_back(&operation_.operand_);
}
while (!lhs_op_.empty()) {
lhs_op const & top_ = lhs_op_.top();
output_.emplace_back(top_.lhs_, top_.operator_, output_.size());
lhs_op_.pop();
}
output_.emplace_front(&_input.first_);
return operator () (output_.back());
}
}
示例4: enqueue_front
void enqueue_front(IoRef &&io) {
queue.emplace_front(std::move(io));
}
示例5: push
void push(task&& t)
{
std::lock_guard<mutex_type> l(_mutex);
_tasks.emplace_front(std::move(t));
}
示例6: bad_emplace_front_deque1
void bad_emplace_front_deque1(std::deque<int> &D, int n) {
auto i0 = D.cbegin(), i1 = D.cend();
D.emplace_front(n);
*i0; // expected-warning{{Invalidated iterator accessed}}
--i1; // expected-warning{{Invalidated iterator accessed}}
}