据我了解,它使用起来会更容易和更清晰,EnumSet
而且它Set
是专门为与枚举器一起使用而设计的。我的问题是我们是否应该考虑在EnumSet
每次需要维护一些枚举器集合时使用。例如,我让他关注枚举:
public enum ReportColumns{
ID,
NAME,
CURRENCY
//It may contain much more enumerators than I mentioned here
public int getMaintenanceValue(){
//impl
}
}
我需要在方法中使用一些枚举集合:
public void persist(Collection<ReportColumns> cols){
List<Integer> ints = new LinkedList<>();
for(ReportColumn c: cols){
ints.add(c.getMaintenanceValue());
}
//do some persistance-related operations
}
那么,如果我不关心集合是否已订购,我应该EnumSet<E>
每次都使用它来提高性能吗?