[era_invalidate] Change to output ranges.

This commit is contained in:
Joe Thornber 2014-02-12 11:49:41 +00:00
parent 5fe5d213b7
commit 54f38e6702
1 changed files with 24 additions and 3 deletions

View File

@ -94,6 +94,20 @@ namespace {
//--------------------------------
template <typename Iterator>
pair<uint32_t, uint32_t> next_run(Iterator &it, Iterator end) {
uint32_t b, e;
b = *it++;
e = b + 1;
while (it != end && *it == e) {
e++;
it++;
}
return make_pair(b, e);
}
void emit_blocks(ostream &out, set<uint32_t> const &blocks) {
indented_stream o(out);
@ -102,10 +116,17 @@ namespace {
o.inc();
{
set<uint32_t>::const_iterator it;
for (it = blocks.begin(); it != blocks.end(); ++it) {
set<uint32_t>::const_iterator it = blocks.begin();
while (it != blocks.end()) {
o.indent();
o << "<block block=\"" << *it << "\"/>" << endl;
pair<uint32_t, uint32_t> range = next_run(it, blocks.end());
if (range.second - range.first == 1)
o << "<block block=\"" << range.first << "\"/>" << endl;
else
o << "<range begin=\"" << range.first
<< "\" end = \"" << range.second << "\"/>" << endl;
}
}
o.dec();