package waymaker.gen; // Copyright © 2015 Michael Allan. Licence MIT. -*-javaM-*- /** More utilities for working with collections. */ public @ThreadSafe final class CollectionsX { private CollectionsX() {} // /** Constructs an array of the collection’s elements. // */ // public static @SuppressWarnings("unchecked") E[] toArray( final Collection col ) // { // return col.toArray( (E[])ObjectX.EMPTY_OBJECT_ARRAY/*spare the garbage collection*/ ); // } /// Fails with ClassCastException in toArray when col is empty. (Somehow I mistakenly assumed an array /// could be treated as a type parameterized collection.) Apparently there's no good alternative to the /// clumsy boilerplate of "col.toArray( new E[col.size()] )". See also the comment ArraysX.newArray. }