fix mixed index / iterator loop condition

replaced end with size
This commit is contained in:
eyal bari 2016-05-03 11:02:33 +03:00
parent 2f0fab5632
commit e41f3f85f8

View File

@ -8166,7 +8166,7 @@ Conventional short, local names increase readability:
template<typename T> // good template<typename T> // good
void print(ostream& os, const vector<T>& v) void print(ostream& os, const vector<T>& v)
{ {
for (int i = 0; i < v.end(); ++i) for (int i = 0; i < v.size(); ++i)
os << v[i] << '\n'; os << v[i] << '\n';
} }
@ -8176,7 +8176,7 @@ An index is conventionally called `i` and there is no hint about the meaning of
void print(ostream& target_stream, const vector<Element_type>& current_vector) void print(ostream& target_stream, const vector<Element_type>& current_vector)
{ {
for (int current_element_index = 0; for (int current_element_index = 0;
current_element_index < current_vector.end(); current_element_index < current_vector.size();
++current_element_index ++current_element_index
) )
target_stream << current_vector[i] << '\n'; target_stream << current_vector[i] << '\n';