I'm writing a c++
method that needs to update some chars in an open file (ofstream
).
The method gets as an input a map, where the key is an offset (position in a file) and the value is a char.
Code sample
typedef map<int,char> IntChar_map;
void update_file(const IntChar_map& v)
{
for(IntChar_map::const_iterator it = v.begin(); it != v.end(); ++it)
{
m_stream->seekp(it->first);
m_stream->put(it->second);
}
}
Question
Let's assume the file is large and the offsets in the map are random.
If I iterate through the map in a reverse order, will it increase performance?
Thanks.