由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Question about vector as a class member
相关主题
Is it possible to initialize container in initialization list?问: STL 里面 deque 是怎么实现的?
Question on C++ Access Control (protected)如何得到位数可变的bitset
问一下STL里的queue, and stack 遍历的问题 (转载)C++ 普及课程 (视频):Vector vs Deque
question on reserve() in vector container.C++糟粕和需要避免的。
stl的一个问题问个INTERVIEW QUESTION
In STL, how big is the initial size for a vector?c++里面有什么Container插入是最快的?
问个copy constructor的问题deque的pointer和reference是怎么回事?
how to initialize associate data in STL mapstl container erase in a loop
相关话题的讨论汇总
话题: vector话题: question话题: class话题: myclass话题: member
进入Programming版参与讨论
1 (共1页)
s*****g
发帖数: 5159
1
Say I have a class
t****t
发帖数: 6806
2
i guess you were a java user
in c++ you don't have to initialize v by "v=vector();", or do anything
to release it.
you also don't have to write myClass a=myClass(); just write myClass a; is
enough.

【在 s*****g 的大作中提到】
: Say I have a class
O*******d
发帖数: 20343
3
vector.push_back的效率很低。
t****t
发帖数: 6806
4
may i ask why is that?

【在 O*******d 的大作中提到】
: vector.push_back的效率很低。
O*******d
发帖数: 20343
5
Vector or Deque? Vector的缺点需要Deque来弥补。
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1069897449&id=1073086407
t****t
发帖数: 6806
6
that has nothing to do with low efficiency of vector::push_back(), no?

【在 O*******d 的大作中提到】
: Vector or Deque? Vector的缺点需要Deque来弥补。
: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1069897449&id=1073086407

O*******d
发帖数: 20343
7
Vector内部是一块连续的内存。 当capacity用完后,就要把全部数据转到新的更大的
连续内存上。

【在 t****t 的大作中提到】
: that has nothing to do with low efficiency of vector::push_back(), no?
p***o
发帖数: 1252
8
1 You can reserve() if you know the final size.
2 Even w/o reserve, the amortized cost of push_back is still O(1).

【在 O*******d 的大作中提到】
: Vector内部是一块连续的内存。 当capacity用完后,就要把全部数据转到新的更大的
: 连续内存上。

d****p
发帖数: 685
9
Among all STL containers, vector is the fastest if number of elements is
less than a modest number, say 100.

【在 O*******d 的大作中提到】
: vector.push_back的效率很低。
1 (共1页)
进入Programming版参与讨论
相关主题
stl container erase in a loopstl的一个问题
static vector 怎么 initialize ?In STL, how big is the initial size for a vector?
请教用c++读取large file怎么可以快一些?问个copy constructor的问题
Associative container 是 set, multiset, map, multimap 这些东西吗?how to initialize associate data in STL map
Is it possible to initialize container in initialization list?问: STL 里面 deque 是怎么实现的?
Question on C++ Access Control (protected)如何得到位数可变的bitset
问一下STL里的queue, and stack 遍历的问题 (转载)C++ 普及课程 (视频):Vector vs Deque
question on reserve() in vector container.C++糟粕和需要避免的。
相关话题的讨论汇总
话题: vector话题: question话题: class话题: myclass话题: member