Optimize Collections.nCopies().hashCode() and equals()

XMLWordPrintable

        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).

              Assignee:
              Tagir Valeev
              Reporter:
              Tagir Valeev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: