summaryrefslogtreecommitdiffstats
path: root/otautil/include
diff options
context:
space:
mode:
authorxunchang <xunchang@google.com>2019-03-22 16:54:35 +0100
committerTianjie Xu <xunchang@google.com>2019-05-01 21:09:38 +0200
commit311e6ca7b609e578c0ec132440a4ad981db70a9e (patch)
tree206a8c1268e4664cb06890f9835d86e83014ae8a /otautil/include
parentMerge changes I2d42f55a,Ic1b5dbf7 (diff)
downloadandroid_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.gz
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.bz2
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.lz
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.xz
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.zst
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.zip
Diffstat (limited to 'otautil/include')
-rw-r--r--otautil/include/otautil/rangeset.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/otautil/include/otautil/rangeset.h b/otautil/include/otautil/rangeset.h
index e91d02ca6..a18c30e29 100644
--- a/otautil/include/otautil/rangeset.h
+++ b/otautil/include/otautil/rangeset.h
@@ -18,6 +18,7 @@
#include <stddef.h>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -49,6 +50,12 @@ class RangeSet {
// bounds. For example, "3,5" contains blocks 3 and 4. So "3,5" and "5,7" are not overlapped.
bool Overlaps(const RangeSet& other) const;
+ // Returns a subset of ranges starting from |start_index| with respect to the original range. The
+ // output range will have |num_of_blocks| blocks in size. Returns std::nullopt if the input is
+ // invalid. e.g. RangeSet({{0, 5}, {10, 15}}).GetSubRanges(1, 5) returns
+ // RangeSet({{1, 5}, {10, 11}}).
+ std::optional<RangeSet> GetSubRanges(size_t start_index, size_t num_of_blocks) const;
+
// Returns a vector of RangeSets that contain the same set of blocks represented by the current
// RangeSet. The RangeSets in the vector contain similar number of blocks, with a maximum delta
// of 1-block between any two of them. For example, 14 blocks would be split into 4 + 4 + 3 + 3,