|
|
发表于 2008-7-7 13:09:00
|
显示全部楼层
Re: Re: Re:我改学C++,用C++开发游戏,是不是一个错?
instemast: Re: Re:我改学C++,用C++开发游戏,是不是一个错?
我认为stl中iterator的 ++,--这个很好,而java只有一个next,这点很垃圾
比如处理 ui 或者精灵,绘制 和 鼠标处理 的遍历方向是相反的。
哈哈哈哈,又一个天大的笑话,遍历的方向是反的,不会用reverse_iterator吗?
这是 Standard C++ Library 的解释:
An iterator naturally imposes an order on an underlying container of values. For a vector or a map, the order is imposed by increasing index values; for a set, by the increasing order of the elements held in the container. For a list, the order is explicitly derived from the way values are inserted.
A reverse iterator yields values in exactly the reverse order of values given by the standard iterators. For a vector or a list, a reverse iterator generates the last element first, and the first element last. For a set it generates the largest element first, and the smallest element last. Strictly speaking, reverse iterators do not constitute a new category of iterator, but an adaptation of another iterator type. Consequently, we have reverse bidirectional iterators and reverse random access iterators. Any bidirectional or random access iterator can be adapted by the reverse_iterator template.
The list, set, and map datatypes provide a pair of member functions that produce reverse bidirectional iterators. The functions rbegin() and rend() generate iterators that cycle through the underlying container in reverse order. Increments to such iterators move backward, and decrements move forward through the sequence.
Similarly, the vector and deque datatypes provide functions, also named rbegin() and rend(), that produce reverse random access iterators. Subscript and addition operators, as well as increments to such iterators, move backward within the sequence. |
|