CastleProto: track next top explicitly

Repeats may be removed (e.g. by pruning in role aliasing passes)
leaving "holes" in the top map. Track the next top to use explicitly,
rather than using repeats.size().
This commit is contained in:
Justin Viiret
2015-12-03 09:27:57 +11:00
committed by Matthew Barr
parent 8427d83780
commit 748d46c124
3 changed files with 32 additions and 16 deletions

View File

@@ -68,8 +68,12 @@ struct CastleProto {
explicit CastleProto(const PureRepeat &pr);
const CharReach &reach() const;
/** \brief Add a new repeat. */
u32 add(const PureRepeat &pr);
/** \brief Remove a repeat. */
void erase(u32 top);
/**
* \brief Merge in the given repeat, returning the top used.
*
@@ -84,6 +88,12 @@ struct CastleProto {
/** \brief Mapping from report to associated tops. */
ue2::unordered_map<ReportID, flat_set<u32>> report_map;
/**
* \brief Next top id to use. Repeats may be removed without top remapping,
* so we track this explicitly instead of using repeats.size().
*/
u32 next_top = 1;
};
std::set<ReportID> all_reports(const CastleProto &proto);