本文整理汇总了C++中std::deque::back方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::back方法的具体用法?C++ deque::back怎么用?C++ deque::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: getc
//input functions
virtual char getc() {
if(gatep==0)throw "virtual char iologgate::getc() gate adress error";
if((Log.size()==0) || Log.back().check(1))Log.push_back(iologType(1));
char tmp=gatep->getc();
Log.back().log(tmp);
return tmp;
}
示例3:
std::deque<timestamp_t> interp_timestamps(const std::deque<timestamp_t> &t0,
const std::deque<timestamp_t> &t1) {
// Determine whether t0 or t1 has a higher rate?
// Then create interpolation timestamps
timestamp_t ts_start = 0;
timestamp_t ts_end = 0;
std::deque<timestamp_t> base_timestamps;
if (t0.size() > t1.size()) {
ts_start = t1.front();
ts_end = t1.back();
base_timestamps = t0;
} else {
ts_start = t0.front();
ts_end = t0.back();
base_timestamps = t1;
}
// Form interpolation timestamps
std::deque<timestamp_t> interp_ts;
for (const auto ts : base_timestamps) {
if (ts > ts_start && ts < ts_end) {
interp_ts.push_back(ts);
}
}
return interp_ts;
}
示例4: 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;
}
}
示例5: join
void sdl_handler::join() {
// this assert will fire if someone will inadvertedly try to join
// an event context but might end up in the global context instead.
assert(&event_contexts.back() != &event_contexts.front());
join(event_contexts.back());
}
示例6: raise_process_event
void raise_process_event()
{
if(event_contexts.empty() == false) {
event_contexts.back().add_staging_handlers();
const handler_list& event_handlers = event_contexts.back().handlers;
for(auto handler : event_handlers) {
handler->process_event();
}
}
}
示例7: 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();
}
}
示例8: raise_draw_event
void raise_draw_event()
{
if(event_contexts.empty() == false) {
event_contexts.back().add_staging_handlers();
const handler_list& event_handlers = event_contexts.back().handlers;
//events may cause more event handlers to be added and/or removed,
//so we must use indexes instead of iterators here.
for(auto handler : event_handlers) {
handler->draw();
}
}
}
示例9: 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;
}
}
}
示例10: TagClasses
void Parser::TagClasses(std::string &cclass, std::string coding,
std::map<std::string, std::string> *values,
std::deque<TokenNode *> &nodes)
{
int n = addressClasses.size();
int bytes = (n + 7)/8;
BYTE *b = new BYTE[bytes];
memset(b, 0, bytes);
std::string temp = cclass;
while (temp.size())
{
int npos = temp.find_first_not_of(", \t");
if (npos == std::string::npos)
break;
int npos1 = temp.find_first_of(", \t", npos+1);
if (npos1 == std::string::npos)
{
npos1 = temp.size();
}
std::string cclass = temp.substr(npos, npos1-npos);
temp.replace(0,npos1,"");
AddressClass *p = addressClasses[cclass];
if (!p)
{
return ;
}
b[(p->id-1)/8] |= (1 << ((p->id-1) & 7));
}
for (std::deque<TokenNode *>::iterator it = nodes.begin(); it != nodes.end(); ++it)
{
(*it)->SetBytes(b, bytes);
}
if (nodes.size())
{
if (coding != "")
{
std::map<std::string, int>::iterator it = codings.find(coding);
n = codings.size() + 1;
if (it == codings.end())
codings[coding] = n;
else
n = it->second;
nodes.back()->coding = n;
}
nodes.back()->eos = 1;
if (values->size())
nodes.back()->values = values;
}
delete b;
}
示例11: 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;
}
示例12: allocateMpfrFloatData
MpfrFloatData* allocateMpfrFloatData(bool initToZero)
{
if(mFirstFreeNode)
{
MpfrFloatData* node = mFirstFreeNode;
mFirstFreeNode = node->nextFreeNode;
if(initToZero) mpfr_set_si(node->mFloat, 0, GMP_RNDN);
++(node->mRefCount);
return node;
}
mData.push_back(MpfrFloatData());
mpfr_init2(mData.back().mFloat, mDefaultPrecision);
if(initToZero) mpfr_set_si(mData.back().mFloat, 0, GMP_RNDN);
return &mData.back();
}
示例13: PruneDeque
void PruneDeque(std::deque<PresentEvent> &presentHistory, uint64_t perfFreq, uint32_t msTimeDiff, uint32_t maxHistLen) {
while (!presentHistory.empty() &&
(presentHistory.size() > maxHistLen ||
((double)(presentHistory.back().QpcTime - presentHistory.front().QpcTime) / perfFreq) * 1000 > msTimeDiff)) {
presentHistory.pop_front();
}
}
示例14: complete_async
inline void complete_async(char const* name)
{
mutex::scoped_lock l(_async_ops_mutex);
async_t& a = _async_ops[name];
TORRENT_ASSERT(a.refs > 0);
--a.refs;
// don't let this grow indefinitely
if (_wakeups.size() < 100000)
{
_wakeups.push_back(wakeup_t());
wakeup_t& w = _wakeups.back();
w.timestamp = clock_type::now();
#ifdef __MACH__
task_events_info teinfo;
mach_msg_type_number_t t_info_count = task_events_info_count;
task_info(mach_task_self(), TASK_EVENTS_INFO,
reinterpret_cast<task_info_t>(&teinfo), &t_info_count);
w.context_switches = teinfo.csw;
#else
w.context_switches = 0;
#endif
w.operation = name;
}
}
示例15: 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);
}