/** * Creates a new HashTree and adds all the objects in the given collection * as top-level nodes in the tree. * * @param keys * a collection of objects to be added to the created HashTree. */ public HashTree(Collection<?> keys) { data = new HashMap<Object, HashTree>(); for (Object o : keys) { data.put(o, new HashTree()); } }
/** * Creates a new HashTree and adds all the objects in the given array as * top-level nodes in the tree. */ public HashTree(Object[] keys) { data = new HashMap<Object, HashTree>(); for (int x = 0; x < keys.length; x++) { data.put(keys[x], new HashTree()); } }
Clone fragments detected by clone detection tool
File path: /apache-jmeter-2.11/src/jorphan/org/apache/jorphan/collections/HashTree.java File path: /apache-jmeter-2.11/src/jorphan/org/apache/jorphan/collections/HashTree.java
Method name: void HashTree(Collection) Method name: void HashTree(Object[])
Number of AST nodes: 2 Number of AST nodes: 2
1
/**
1
/**
2
     * Creates a new HashTree and adds all the objects in the given collection
2
     * Creates a new HashTree and adds all the objects in the given array as
3
     * as top-level nodes in the tree.
3
     * top-level nodes in the tree.
4
     *
4
     */
5
     * @param keys
5
    public HashTree(Object[] keys) {
6
     *            a collection of objects to be added to the created HashTree.
6
        data = new HashMap<Object, HashTree>();
7
     */
7
        for (int x = 0; x < keys.length; x++) {
8
    public HashTree(Collection<?> keys) {
8
            data.put(keys[x], new HashTree());
9
        data = new HashMap<Object, HashTree>();
9
        }
10
        for (Object o : keys) {
10
    }
11
            data.put(o, new HashTree());
12
        }
13
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    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.500
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    for (Object o : keys)
    2
    for (Object o : keys)
    2
    for (int x = 0; x < keys.length; x++)
    Differences
    Expression1Expression2Difference
    java.util.Collection<>java.lang.Object[]VARIABLE_TYPE_MISMATCH
    java.util.Collection<>java.lang.Object[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<> of variable keys does not match with type java.lang.Object[] of variable keys
    • Make classes java.util.Collection<> and java.lang.Object[] extend a common superclass
    Type java.util.Collection<> of variable keys does not match with type java.lang.Object[] of variable keys
    • Make classes java.util.Collection<> and java.lang.Object[] extend a common superclass
    2
    for (int x = 0; x < keys.length; x++)
    3
    data.put(o, new HashTree());
    3
    data.put(o, new HashTree());
    3
    data.put(keys[x], new HashTree());
    Differences
    Expression1Expression2Difference
    okeys[x]TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression o cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression keys[x] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    data.put(keys[x], new HashTree());
    Precondition Violations (4)
    Row Violation
    1Type java.util.Collection<> of variable keys does not match with type java.lang.Object[] of variable keys
    2Type java.util.Collection<> of variable keys does not match with type java.lang.Object[] of variable keys
    3Expression o cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression keys[x] cannot be parameterized, because it has dependencies to/from statements that will be extracted