title: Enum.values() vs EnumSet.allOf( ). Which one is more preferable?
body: <p>I looked under the hood for <code>EnumSet.allOf</code> and it looks very efficient, especially for enums with less than 64 values.</p>
  
  <p>Basically all sets share the single array of all possible enum values and the only other piece of information is a bitmask which in case of <code>allOf</code> is set in one swoop.</p>
  
  <p>On the other hand Enum.values() seems to be a bit of black magic. Moreover it returns an array, not a collection, so in many cases it must be decorated with Arrays.asList( ) to be usable in any place that expects collection.</p>
  
  <p>So, should <code>EnumSet.allOf</code> be more preferable to <code>Enum.values</code>?</p>
  
  <p>More specifically, which form of <code>for</code> iterator should be used:</p>
  
  <pre><code>for ( final MyEnum val: MyEnum.values( ) );
  </code></pre>
  
  <p>or</p>
  
  <pre><code>for ( final MyEnum val: EnumSet.allOf( MyEnum.class ) );
  </code></pre>