/**
* 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 | } | | | |
See real code fragment |
|
See real code fragment |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 0.333 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
6 | while (iter.hasNext()) | | 2 | for (Iterator i = ((ResourceCollection)o).iterator(); i.hasNext(); ) |
7 | | | 3 | |
Precondition Violations (0)
Row |
Violation |