Redian新闻
>
Master of science in information system NEU Bo
avatar
Master of science in information system NEU Bo# Computation - 科学计算
h*d
1
Here’s a short video clip that was a real blessing to me as I watched and
listened to it. It is part of the history of the song Amazing Grace by
Wintley Phipps. It is a true blessing:
http://www.youtube.com/watch?v=DMF_24cQqT0.
God has gifted him with an amazing voice. And as one person commented on
the youtube site, “If it don't light your fire, then my friend your wood is
wet! This is awesome!”
avatar
x*n
2
怪想念的。
avatar
b*y
3
copy(a.begin(), a.end(), inserter(b, b.begin());
copy(a.begin(), a.end(), front_inserter(b)); //inverse order of a.
这两行的结果是不同的。是不是每插入一个a的element,都要调用一次后面的inserter
,因此也就每次都调用b.begin()?这样用inserter插入的,也应该是倒序啊。
avatar
s*g
4
NEU IS in Boston请给个建议,还有个GWU 的CS offer,
avatar
z*r
5
忙运动呢,厚厚

【在 x*********n 的大作中提到】
: 怪想念的。
avatar
t*t
6
inserter() returns a insert_iterator, which calls container.insert() each
time insert_iterator::operator= is called. The begin() is stored in the
insert_iterator. Thus it has limitations. For some sequential containers,
such as vector, insert() may invalidate the calculated (only once) begin(),
so it could be undefined.
back_inserter() returns a back_insert_iterator, which calls container.push_
back() each time back_insert_iterator::operator= is called. Thus it only
works for sequential containe

【在 b***y 的大作中提到】
: copy(a.begin(), a.end(), inserter(b, b.begin());
: copy(a.begin(), a.end(), front_inserter(b)); //inverse order of a.
: 这两行的结果是不同的。是不是每插入一个a的element,都要调用一次后面的inserter
: ,因此也就每次都调用b.begin()?这样用inserter插入的,也应该是倒序啊。

avatar
t*r
7
冒个泡儿 :-)
avatar
b*y
8
you mean insert_iterator can't be used on vecters because inserting into a
vector always invalidated the iteraters after that position?

,
push_

【在 t****t 的大作中提到】
: inserter() returns a insert_iterator, which calls container.insert() each
: time insert_iterator::operator= is called. The begin() is stored in the
: insert_iterator. Thus it has limitations. For some sequential containers,
: such as vector, insert() may invalidate the calculated (only once) begin(),
: so it could be undefined.
: back_inserter() returns a back_insert_iterator, which calls container.push_
: back() each time back_insert_iterator::operator= is called. Thus it only
: works for sequential containe

avatar
t*t
9
for vector:
Reallocation invalidates all the references, pointers, and iterators
referring to the elements in the sequence. It is guaranteed that no
reallocation takes place during insertions that happen after a call
to reserve() until the time when an insertion would make the size of
the vector greater than the size specified in the most recent call
to reserve().
for deque:
An insert in the middle of the deque invalidates all the iterators
and references to

【在 b***y 的大作中提到】
: you mean insert_iterator can't be used on vecters because inserting into a
: vector always invalidated the iteraters after that position?
:
: ,
: push_

avatar
b*y
10
thanks for your explanation. I think inserter can be used on list even it
's a sequential container. What's the point to use inserter on associative
containers?

【在 t****t 的大作中提到】
: for vector:
: Reallocation invalidates all the references, pointers, and iterators
: referring to the elements in the sequence. It is guaranteed that no
: reallocation takes place during insertions that happen after a call
: to reserve() until the time when an insertion would make the size of
: the vector greater than the size specified in the most recent call
: to reserve().
: for deque:
: An insert in the middle of the deque invalidates all the iterators
: and references to

avatar
t*t
11
yes, you can use inserter on list<>, since insertion on list doesn't
invalidate iterator. however, since list<> can be splice()'ed with constant
time, i think inserter on list<> is rarely needed.
for associative container, e.g.
set x;
copy(istream_iterator(cin), istream_iterator(), inserter(x, x.
begin());

it

【在 b***y 的大作中提到】
: thanks for your explanation. I think inserter can be used on list even it
: 's a sequential container. What's the point to use inserter on associative
: containers?

avatar
b*y
12
多谢了。

constant

【在 t****t 的大作中提到】
: yes, you can use inserter on list<>, since insertion on list doesn't
: invalidate iterator. however, since list<> can be splice()'ed with constant
: time, i think inserter on list<> is rarely needed.
: for associative container, e.g.
: set x;
: copy(istream_iterator(cin), istream_iterator(), inserter(x, x.
: begin());
:
: it

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。