auto 使用与emplace

589N叉树遍历

vector<Node*>children;

for(auto &ch:children){}

stack(Node*)st;

Node* node=st.pop();

for(auto it=node->children.rbegin();it!=node.rend();it++) {   //rbegin和rend逆序迭代器

  st.emplace(*it);//emplace和emplace_back()都是调用构造函数;在栈顶加入STL:stack emplace()

}

一般emplace(iteractor pos,arg)在pos位置前方插入arg

posted @ 2023-04-06 15:14  iu本u  阅读(16)  评论(0)    收藏  举报