/** * Sort the contained elements. * @return a Collection of Resources. */ protected synchronized Collection getCollection() { ResourceCollection rc = getResourceCollection(); Iterator iter = rc.iterator(); if (!(iter.hasNext())) { return Collections.EMPTY_SET; } SortedBag b = new SortedBag(comp); while (iter.hasNext()) { b.add(iter.next()); } return b; }
private ArrayList collect(Object o) { ArrayList result = new ArrayList(); for (Iterator i = ((ResourceCollection) o).iterator(); i.hasNext();) { result.add(i.next()); } return result; }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/resources/Sort.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/resources/Intersect.java
Method name: Collection getCollection() Method name: ArrayList collect(Object)
Number of AST nodes: 2 Number of AST nodes: 2
1
/**
1
private ArrayList collect(Object o) {
2
     * Sort the contained elements.
2
        ArrayList result = new ArrayList();
3
     * @return a Collection of Resources.
3
        for (Iterator i = ((ResourceCollection) o).iterator(); i.hasNext();) {
4
     */
4
            result.add(i.next());
5
    protected synchronized Collection getCollection() {
5
        }
6
        ResourceCollection rc = getResourceCollection();
6
        return result;
7
        Iterator iter = rc.iterator();
7
    }
8
        if (!(iter.hasNext())) {
9
            return Collections.EMPTY_SET;
10
        }
11
        SortedBag b = new SortedBag(comp);
12
        while (iter.hasNext()) {
13
            b.add(iter.next());
14
        }
15
        return b;
16
    }
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.333
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    while (iter.hasNext())
    6
    while (iter.hasNext())
    2
    for (Iterator i = ((ResourceCollection)o).iterator(); i.hasNext(); )
    Differences
    Expression1Expression2Difference
    iteriVARIABLE_NAME_MISMATCH
    rc((ResourceCollection)o)TYPE_COMPATIBLE_REPLACEMENT
    2
    for (Iterator i = ((ResourceCollection)o).iterator(); i.hasNext(); )
    7
    b.add(iter.next());
    7
    b.add(iter.next());
    3
    result.add(i.next());
    Differences
    Expression1Expression2Difference
    iteriVARIABLE_NAME_MISMATCH
    bresultVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.resources.Sort.SortedBagjava.util.ArrayListSUBCLASS_TYPE_MISMATCH
    3
    result.add(i.next());
    Precondition Violations (0)
    Row Violation