[space-map] Add new virtual methods to inc or dec by a specific amount.

Provide default implementation that just loops
This commit is contained in:
Joe Thornber 2020-05-26 08:29:52 +01:00
parent 5e6eec1bb0
commit 2ed089a83f

View File

@ -48,6 +48,17 @@ namespace persistent_data {
virtual void inc(block_address b) = 0; virtual void inc(block_address b) = 0;
virtual void dec(block_address b) = 0; virtual void dec(block_address b) = 0;
// slow default implementation
virtual void inc(block_address b, uint32_t count) {
for (uint32_t i = 0; i < count; i++)
inc(b);
}
virtual void dec(block_address b, uint32_t count) {
for (uint32_t i = 0; i < count; i++)
dec(b);
}
// FIXME: change these to return an optional, failure is // FIXME: change these to return an optional, failure is
// not that rare if we're restricting the area that's // not that rare if we're restricting the area that's
// searched. // searched.