RFR: 8304759: Add BitMap iterators [v2]
Kim Barrett
kbarrett at openjdk.org
Wed Mar 29 16:18:34 UTC 2023
On Wed, 29 Mar 2023 09:31:40 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
>> src/hotspot/share/utilities/bitMap.hpp line 420:
>>
>>> 418: // Returns the index of the last set bit in the remaining iteration range.
>>> 419: // precondition: !is_empty()
>>> 420: idx_t last() const;
>>
>> The comments for `first()` and `last()` are a little misleading. The invariant that the `first()`/`last()` is a set bit is only true for `first()` in the forward iterator and for `last()` in the reverse iterator.
>>
>> It seems more like a contract that if you use `first()` then you must have created `IteratorImpl(const BitMap* map, idx_t beg, idx_t end)` with `beg` being a set bit. And if you use `last()` then you must have created it with `end-1` being a set bit.
>
> Or `beg == end`, that is an `is_empty()` Iterator
Yes, you are correct. Some of the comments for IteratorImpl didn't get properly updated. I'll clean that up.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13184#discussion_r1152186946
More information about the hotspot-dev
mailing list