-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P3
-
Affects Version/s: 8
-
Component/s: core-libs
-
None
More spliterator characteristics for EnumSet (and perhaps also optimized collection implementations for methods like forEach)
import java.util.*;
public class EnumSetSpliterator {
enum RegularEnum {
e00, e01, e02, e03, e04, e05, e06, e07,
}
enum JumboEnum {
e00, e01, e02, e03, e04, e05, e06, e07,
e08, e09, e0A, e0B, e0C, e0D, e0E, e0F,
e10, e11, e12, e13, e14, e15, e16, e17,
e18, e19, e1A, e1B, e1C, e1D, e1E, e1F,
e20, e21, e22, e23, e24, e25, e26, e27,
e28, e29, e2A, e2B, e2C, e2D, e2E, e2F,
e30, e31, e32, e33, e34, e35, e36, e37,
e38, e39, e3A, e3B, e3C, e3D, e3E, e3F,
e40, e41, e42, e43, e44, e45, e46, e47,
e48, e49, e4A, e4B, e4C, e4D, e4E, e4F,
}
static void printCharacteristics(Collection<?> coll) {
System.out.println(coll.getClass().getSimpleName());
int c = coll.spliterator().characteristics();
if ((c & Spliterator.SIZED) != 0) System.out.println("SIZED");
if ((c & Spliterator.SUBSIZED) != 0) System.out.println("SUBSIZED");
if ((c & Spliterator.IMMUTABLE) != 0) System.out.println("IMMUTABLE");
if ((c & Spliterator.CONCURRENT) != 0) System.out.println("CONCURRENT");
if ((c & Spliterator.ORDERED) != 0) System.out.println("ORDERED");
if ((c & Spliterator.DISTINCT) != 0) System.out.println("DISTINCT");
if ((c & Spliterator.SORTED) != 0) System.out.println("SORTED");
if ((c & Spliterator.NONNULL) != 0) System.out.println("NONNULL");
}
public static void main(String[] args) throws Throwable {
printCharacteristics(EnumSet.of(RegularEnum.e03));
printCharacteristics(EnumSet.of(JumboEnum.e03));
}
}
=>
RegularEnumSet
SIZED
SUBSIZED
DISTINCT
JumboEnumSet
SIZED
SUBSIZED
DISTINCT
import java.util.*;
public class EnumSetSpliterator {
enum RegularEnum {
e00, e01, e02, e03, e04, e05, e06, e07,
}
enum JumboEnum {
e00, e01, e02, e03, e04, e05, e06, e07,
e08, e09, e0A, e0B, e0C, e0D, e0E, e0F,
e10, e11, e12, e13, e14, e15, e16, e17,
e18, e19, e1A, e1B, e1C, e1D, e1E, e1F,
e20, e21, e22, e23, e24, e25, e26, e27,
e28, e29, e2A, e2B, e2C, e2D, e2E, e2F,
e30, e31, e32, e33, e34, e35, e36, e37,
e38, e39, e3A, e3B, e3C, e3D, e3E, e3F,
e40, e41, e42, e43, e44, e45, e46, e47,
e48, e49, e4A, e4B, e4C, e4D, e4E, e4F,
}
static void printCharacteristics(Collection<?> coll) {
System.out.println(coll.getClass().getSimpleName());
int c = coll.spliterator().characteristics();
if ((c & Spliterator.SIZED) != 0) System.out.println("SIZED");
if ((c & Spliterator.SUBSIZED) != 0) System.out.println("SUBSIZED");
if ((c & Spliterator.IMMUTABLE) != 0) System.out.println("IMMUTABLE");
if ((c & Spliterator.CONCURRENT) != 0) System.out.println("CONCURRENT");
if ((c & Spliterator.ORDERED) != 0) System.out.println("ORDERED");
if ((c & Spliterator.DISTINCT) != 0) System.out.println("DISTINCT");
if ((c & Spliterator.SORTED) != 0) System.out.println("SORTED");
if ((c & Spliterator.NONNULL) != 0) System.out.println("NONNULL");
}
public static void main(String[] args) throws Throwable {
printCharacteristics(EnumSet.of(RegularEnum.e03));
printCharacteristics(EnumSet.of(JumboEnum.e03));
}
}
=>
RegularEnumSet
SIZED
SUBSIZED
DISTINCT
JumboEnumSet
SIZED
SUBSIZED
DISTINCT
- links to
-
Review(master)
openjdk/jdk/28568