33 template<
size_t COUNT_BITS>
37 static_assert(COUNT_BITS <= 32,
"COUNT_BITS max exceeded");
46 static constexpr uint32_t
count_mask = (1ul << COUNT_BITS) - 1;
51 static constexpr uint64_t
start_max = (1ul << (64 - COUNT_BITS)) - 1;
62 assert(count <= count_mask);
63 assert(start <= start_max);
83 return o_ >> COUNT_BITS;
112 assert(count <= count_mask);
113 o_ = (o_ & ~count_mask) | count;
122 assert(start <= start_max);
123 o_ = (o_ &
count_mask) | (start << COUNT_BITS);
132 std::pair<size_t, size_t>
range()
const {
133 uint64_t s =
start();
134 return {s, s +
count()};
uint32_t count() const
Get the count (number) of elements represented by this offset range.
Definition: offset.hh:91
std::pair< size_t, size_t > range() const
Get the range (start index to end index, inclusive) represented by this offset range.
Definition: offset.hh:132
offset represents an offset range (a start index plus a count of elements) in a single uint64_t...
Definition: offset.hh:34
void set_count(uint32_t count)
Set the count of this offset range.
Definition: offset.hh:111
uint64_t start() const
Get the start index of the offset range.
Definition: offset.hh:82
uint64_t end() const
Get the index pointing one element past the final element represented by this offset range...
Definition: offset.hh:102
static constexpr uint32_t count_mask
Bitmask used to get the count bits, this is also the maximum value for the count value.
Definition: offset.hh:46
offset(uint64_t start, uint32_t count)
Construct a new offset range from a start index and a count.
Definition: offset.hh:61
offset(const offset &prev, uint32_t count)
Construct a new offset range from a previous offset range and a count. The start index of this offset...
Definition: offset.hh:75
static constexpr uint64_t start_max
The maximum value of the start index value.
Definition: offset.hh:51
Definition: control.hh:31
void set_offset(uint64_t start)
Set the start index of this offset range.
Definition: offset.hh:121