《泛型编程与STL》读后感1--持续更新中
2010-12-16 00:19 Rollen Holt 阅读(352) 评论(0) 编辑 收藏 举报《泛型编程与STL》学习感悟
1在C语言中有3种不同类型的指针:<1>普通而且有效的指针。比如&A[0];<2>非法指针,比如NULL<3>"past-the-end"指针,我们不能对其进行提领动作,但是可以用于指针运算。比如int A[10];我们不能用&A[10].
2 虽然我们可以对于迭代器Iterator进行提领运算。但是这个并不能说明Iterator是一个指针。而仅仅是说明Iterator必须支持类似指针的接口。
3 operator++中。如果是operator++() 则说明是前++,如果是operator++(int ),则是后++、
4 Input Iterator并不能提供更改【iterator所指之物】的方法、也就是说具有只读性。但是output iterator只具有只写性。并且用这两个迭代器的算法只能是“单回的”。任何时候任何区间只能有一个Input Iterator或者output iterator有效的迭代器。其他的迭代器具体的描述如下:
Iterator |
Description |
input_iterator |
Read values with forward movement. These can be incremented, compared, and dereferenced. |
output_iterator |
Write values with forward movement. These can be incremented and dereferenced. |
forward_iterator |
Read or write values with forward movement. These combine the functionality of input and output iterators with the ability to store the iterators value. |
bidirectional_iterator |
Read and write values with forward and backward movement. These are like the forward iterators, but you can increment and decrement them. |
random_iterator |
Read and write values with random access. These are the most powerful iterators, combining the functionality of bidirectional iterators with the ability to do pointer arithmetic and pointer comparisons. |
reverse_iterator |
Either a random iterator or a bidirectional iterator that moves in reverse direction. |
Each of the container classes is associated with a type of iterator, and each of the STL algorithms uses a certain type of iterator. For example, vectors are associated with random-access iterators, which means that they can use algorithms that require random access. Since random-access iterators encompass all of the characteristics of the other iterators, vectors can use algorithms designed for other iterators as well.
==============================================================================
本博客已经废弃,不在维护。新博客地址:http://wenchao.ren
我喜欢程序员,他们单纯、固执、容易体会到成就感;面对压力,能够挑灯夜战不眠不休;面对困难,能够迎难而上挑战自我。他
们也会感到困惑与傍徨,但每个程序员的心中都有一个比尔盖茨或是乔布斯的梦想“用智慧开创属于自己的事业”。我想说的是,其
实我是一个程序员
==============================================================================