Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-540

Duplication of code in CollectionUtils

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1
    • Component/s: None
    • Labels:
      None

      Description

      In CollectionUtils.get(Object, int) on Line 1250, the code in the condition:

      CollectionUtils.java
      else if (object instanceof Iterator<?>) {
          final Iterator<?> it = (Iterator<?>) object;
          while (it.hasNext()) {
              i--;
              if (i == -1) {
                  return it.next();
              }
              it.next();
           }
           throw new IndexOutOfBoundsException("Entry does not exist: " + i);
      }
      

      Can be replaced with just a call to CollectionUtils.get(Iterator, int), on Line 1176.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dstewart Daniel Stewart
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: