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

Duplication of code in CollectionUtils

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 4.0
    • 4.1
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: