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

Improve enum iteration



    • Enhancement
    • Resolution: Fixed
    • P4
    • 16
    • 16
    • hotspot
    • b28


      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.


        Issue Links



              kbarrett Kim Barrett
              kbarrett Kim Barrett
              0 Vote for this issue
              3 Start watching this issue