interface and be mutually comparable.
publictreeMap(Map<? extends K,? extends V> map)
Equivalent to using TReeMap() and then adding all the key/value pairs of
map to this map.
publicTReeMap(Comparator<? super K> comp)
Creates a new TReeMap that is sorted according to the order imposed by
comp.
publictreeMap(SortedMap<K,? extends V> map)
Creates a new TReeMap whose initial contents will be the same as those in
map and that is sorted the same way as map.
21.9. enum Collections
Two collections, EnumSet and EnumMap, are specifically designed for working efficiently with enum
constants.
21.9.1. EnumSet
The abstract class EnumSet<EextendsEnum
from a specific enum type. Suppose you were writing a reflection related API, you could define an enum of
the different field modifiers, and then have your Field class return the set of modifiers applicable to that
field:
enum FieldModifiers { STATIC, FINAL, VOLATILE, TRANSIENT }
public class Field {
public EnumSet
// ...
}
// ... rest of Field methods ...
}
In general, whenever an enum represents a set of flags or "status bits," then you will probably want to group
the set of flags applicable to a given element in an enum set.
EnumSet objects are not created directly but are obtained from a number of static factory methods in
EnumSet.
public static <E extends Enum<E>> EnumSet<E>allOf(Class<E>
enumType)
Creates an EnumSet containing all the elements of the given enum type.
public static <E extends Enum<E>> EnumSet<E>noneOf(Class<E>
enumType)