@@ -55,8 +55,6 @@ template <typename BitSetType> class rle_decoder {
55
55
// - a positive number for the number of consecutive 1's
56
56
// - zero if there are no more bits to decode
57
57
//
58
- // This encoding is to support efficient intersection using a min-heap
59
- //
60
58
// Can traverse only a single time.
61
59
class chunk_enumerator {
62
60
public:
@@ -70,18 +68,14 @@ template <typename BitSetType> class rle_decoder {
70
68
}
71
69
72
70
// Get the current chunk of continuous bits. -ve values are 0s
73
- // +ve values are 1s. range is -255...255. will return 0 if
71
+ // +ve values are 1s. range is -255...255. will return 0 if finished
74
72
[[nodiscard]] constexpr auto bit_chunk () const -> std::int_fast16_t {
75
73
return bit_value ? current_run : -current_run;
76
74
}
77
75
78
76
// Advance the bit chunk by the given number of bits. This might consume
79
77
// only a portion of the remain bits in the chunk, skip to the next
80
78
// chunk or skip over multiple chunks.
81
- //
82
- // Note: No bounds checking is done for efficiency
83
- // The caller is responsible for ensuring that the bitset bounds
84
- // are not exceeded while consuming data.
85
79
constexpr void advance (std::size_t bits) {
86
80
while (bits > 0 && bits_remaining > 0 ) {
87
81
// more available than we are consuming?
@@ -115,7 +109,7 @@ template <typename BitSetType> class rle_decoder {
115
109
return ;
116
110
}
117
111
118
- // skipping the next bit for a >255 run?
112
+ // skipping the next bit count for a > 255 run?
119
113
if (*rle_data == std::byte{0 }) {
120
114
// keep same bit_value and skip this encoded byte
121
115
++rle_data;
@@ -250,7 +244,7 @@ struct rle_intersect {
250
244
// chunks must also be 1s.
251
245
advance (static_cast <std::size_t >(chunk));
252
246
while (chunk-- > 0 ) {
253
- // call F, but abort if returns false
247
+ // call F, but abort if it indicates abort requested
254
248
if (f (bit++)) {
255
249
return true ; // early abort
256
250
}
@@ -296,6 +290,7 @@ struct rle_intersect {
296
290
}
297
291
};
298
292
293
+ // at least 1 decoder is required
299
294
template <typename Decoder, std::same_as<Decoder>... Others>
300
295
rle_intersect (Decoder &&d, Others &&...others)
301
296
-> rle_intersect<typename Decoder::bitset_type, Decoder, Others...>;
0 commit comments