Why is it better to use '!=" than '<' in a vector loop? (C++)

后端 未结 7 1349
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 04:53

Why is it better to use \'!=\" than \'<\' in a vector loop? I just can\'t see the difference.

7条回答
  •  暖寄归人
    2021-01-02 05:41

    For vector iterators, it doesn't make any difference. In general, iterators may not support '<' just '==' and '!='. Hence, the most general way to test if you have not reached the end of the collection is to check if the iterator != container.end()

提交回复
热议问题