L
linq936
Hi,
When I use a vector iterator I normally do this way:
vector<int>::iterator itr = vec.begin();
for (; itr != vec.end(); ++itr ){
}
Note I am comparing if itr equals to vec.end(). I am wondering if I
could use "less than":
for (; itr < vec.end(); ++itr ){
}
I know this is not good in the system that virtual memory is not
used since memory can be segmented. But if we just assume the program
only runs on virtual memory system, then it is ok to write the code
using "less than". Am I right? As I see in virtual memory allocated
memory is always continuous.
When I use a vector iterator I normally do this way:
vector<int>::iterator itr = vec.begin();
for (; itr != vec.end(); ++itr ){
}
Note I am comparing if itr equals to vec.end(). I am wondering if I
could use "less than":
for (; itr < vec.end(); ++itr ){
}
I know this is not good in the system that virtual memory is not
used since memory can be segmented. But if we just assume the program
only runs on virtual memory system, then it is ok to write the code
using "less than". Am I right? As I see in virtual memory allocated
memory is always continuous.