Currently Collections.nCopies().hashCode() delegates to AbstractList.hashCode() which creates an iterator and caculates the hashCode of the same element n times. An optimized implementation is possible which: - Doesn't create an iterator - Calls element.hashCode() at most once - Has O(log(n)) complexity Also specialized implementation of CopiesList.equals() is possible which at least can check whether another object is also a CopiesList (in this case, no iteration is necessary, just compare single element and size).
|