Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8257466

Improve enum iteration

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 16
    • Fix Version/s: 16
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b28

      Description

      Use of the new enum iteration facility has turned up some additional features that would be useful.

      EnumRange and EnumIterator should provide a nested type name for the associated enum type. This is useful when the range or iterator type isn't known but is instead itself a template parameter.

      EnumRange should provide an index operation that converts from an enumerator to a zero-based index into the range. Some applications have arrays where the array elements are 1-1 with the enumerators in the range. Such an index function is useful for mapping from an enumerator value to the corresponding array index. This can be done with conversions to the underlying type, but that's kind of clumsy.

      Some enums have ranges of values rather than named enumerators. There are some additions to EnumIterator and EnumRange that are helpful when working with such enums.

      - EnumRange should provide accessors for the range bounds. One can get them by dereferencing begin and end iterators, but that's kind of clumsy.

      - The underlying EnumeratorRange and EnumTraits infrastructure should be extended to allow the range to be specified as start and (exclusive) end values of the enum's underlying type.

      There also should be unit unit tests for enum iteration.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kbarrett Kim Barrett
              Reporter:
              kbarrett Kim Barrett
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: