RFR: 8304759: Add BitMap iterators [v4]

Kim Barrett kbarrett at openjdk.org
Wed Mar 29 17:22:34 UTC 2023


> Please review this change which adds iteration over the set bit positions of a
> BitMap via an iterator object.  This is in addition to the existing iterate()
> and reverse_iterate() functions that apply a function to the set bit positions.
> 
> There are two iterator classes: BitMap::Iterator and BitMap::ReverseIterator.
> Iteration uses a single, self-contained iterator object, rather than a pair of
> iterator objects as is done with standard library iterators.  This is because
> the desired form of iteration over bitmaps doesn't lend itself well to the
> begin/end pair style.  Typical usage is something like
> 
> 
> for (BitMap::Iterator it{map, beg, end}; !it.is_empty(); it.step()) {
>   ... use it.index()
> }
> 
> 
> However, as a syntactic convenience, these iterator classes provide begin()
> and end() member functions returning objects supporting the requirements for
> range-based for loops.  By constraining these objects to this usage we can
> cope with the "iterator pair" requirements.  Usage is something like
> 
> 
> for (BitMap::idx_t index : BitMap::Iterator{map, beg, end}) {
>   ...
> }
> 
> 
> Testing:
> mach5 tier1, which includes running the updated gtests on all Oracle-supported
> platforms.

Kim Barrett has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:

 - Merge branch 'master' into bm-iterators
 - improve/correct comments for IteratorImpl
 - better names for step functions
 - bitmap iterators

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/13184/files
  - new: https://git.openjdk.org/jdk/pull/13184/files/2ea0b16b..6866fcf4

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=13184&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=13184&range=02-03

  Stats: 7762 lines in 231 files changed: 5254 ins; 1358 del; 1150 mod
  Patch: https://git.openjdk.org/jdk/pull/13184.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13184/head:pull/13184

PR: https://git.openjdk.org/jdk/pull/13184


More information about the hotspot-dev mailing list