DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("C", new Double(1.0)); data.addValue("B", null); data.addValue("D", new Double(3.0)); data.addValue("A", new Double(2.0)); data.sortByKeys(SortOrder.ASCENDING); // check key order assertEquals(data.getKey(0), "A"); assertEquals(data.getKey(1), "B"); assertEquals(data.getKey(2), "C"); assertEquals(data.getKey(3), "D"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(2.0)); assertEquals(data.getValue("B"), null); assertEquals(data.getValue("C"), new Double(1.0)); assertEquals(data.getValue("D"), new Double(3.0)); // check retrieve value by index assertEquals(data.getValue(0), new Double(2.0)); assertEquals(data.getValue(1), null); assertEquals(data.getValue(2), new Double(1.0)); assertEquals(data.getValue(3), new Double(3.0));
DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("C", new Double(1.0)); data.addValue("B", null); data.addValue("D", new Double(3.0)); data.addValue("A", new Double(2.0)); data.sortByValues(SortOrder.ASCENDING); // check key order assertEquals(data.getKey(0), "C"); assertEquals(data.getKey(1), "A"); assertEquals(data.getKey(2), "D"); assertEquals(data.getKey(3), "B"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(2.0)); assertEquals(data.getValue("B"), null); assertEquals(data.getValue("C"), new Double(1.0)); assertEquals(data.getValue("D"), new Double(3.0)); // check retrieve value by index assertEquals(data.getValue(0), new Double(1.0)); assertEquals(data.getValue(1), new Double(2.0)); assertEquals(data.getValue(2), new Double(3.0)); assertEquals(data.getValue(3), null);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValuesTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValuesTests.java
Method name: void testSortByKeyAscending() Method name: void testSortByValueAscending()
Number of AST nodes: 18 Number of AST nodes: 18
1
DefaultKeyedValues data = new DefaultKeyedValues();
1
DefaultKeyedValues data = new DefaultKeyedValues();
2
        data.addValue("C", new Double(1.0));
2
        data.addValue("C", new Double(1.0));
3
        data.addValue("B", null);
3
        data.addValue("B", null);
4
        data.addValue("D", new Double(3.0));
4
        data.addValue("D", new Double(3.0));
5
        data.addValue("A", new Double(2.0));
5
        data.addValue("A", new Double(2.0));
6
        data.sortByKeys(SortOrder.ASCENDING);
6
        data.sortByValues(SortOrder.ASCENDING);
7
        // check key order
7
        // check key order
8
        assertEquals(data.getKey(0), "A");
8
        assertEquals(data.getKey(0), "C");
9
        assertEquals(data.getKey(1), "B");
9
        assertEquals(data.getKey(1), "A");
10
        assertEquals(data.getKey(2), "C");
10
        assertEquals(data.getKey(2), "D");
11
        assertEquals(data.getKey(3), "D");
11
        assertEquals(data.getKey(3), "B");
12
        // check retrieve value by key
12
        // check retrieve value by key
13
        assertEquals(data.getValue("A"), new Double(2.0));
13
        assertEquals(data.getValue("A"), new Double(2.0));
14
        assertEquals(data.getValue("B"), null);
14
        assertEquals(data.getValue("B"), null);
15
        assertEquals(data.getValue("C"), new Double(1.0));
15
        assertEquals(data.getValue("C"), new Double(1.0));
16
        assertEquals(data.getValue("D"), new Double(3.0));
16
        assertEquals(data.getValue("D"), new Double(3.0));
17
        // check retrieve value by index
17
        // check retrieve value by index
18
        assertEquals(data.getValue(0), new Double(2.0));
18
        assertEquals(data.getValue(0), new Double(1.0));
19
        assertEquals(data.getValue(1), null);
19
        assertEquals(data.getValue(1), new Double(2.0));
20
        assertEquals(data.getValue(2), new Double(1.0));
20
        assertEquals(data.getValue(2), new Double(3.0));
21
        assertEquals(data.getValue(3), new Double(3.0));
21
        assertEquals(data.getValue(3), null);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are declared in the same class
Number of node comparisons180
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements18
    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
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValues data = new DefaultKeyedValues();
    1
    DefaultKeyedValues data = new DefaultKeyedValues();
    2
    data.addValue("C", new Double(1.0));
    2
    data.addValue("C", new Double(1.0));
    3
    data.addValue("B", null);
    3
    data.addValue("B", null);
    4
    data.addValue("D", new Double(3.0));
    4
    data.addValue("D", new Double(3.0));
    5
    data.addValue("A", new Double(2.0));
    5
    data.addValue("A", new Double(2.0));
    6
    data.sortByKeys(SortOrder.ASCENDING);
    6
    data.sortByKeys(SortOrder.ASCENDING);
    6
    data.sortByValues(SortOrder.ASCENDING);
    Differences
    Expression1Expression2Difference
    sortByKeyssortByValuesMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression data.sortByKeys(SortOrder.ASCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.sortByValues(SortOrder.ASCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.sortByKeys(SortOrder.ASCENDING) is a void method call, and thus it cannot be parameterized
    Expression data.sortByValues(SortOrder.ASCENDING) is a void method call, and thus it cannot be parameterized
    6
    data.sortByValues(SortOrder.ASCENDING);
    7
    assertEquals(data.getKey(0), "A");
    7
    assertEquals(data.getKey(0), "A");
    8
    assertEquals(data.getKey(1), "A");
    Differences
    Expression1Expression2Difference
    01LITERAL_VALUE_MISMATCH
    8
    assertEquals(data.getKey(1), "A");
    8
    assertEquals(data.getKey(1), "B");
    8
    assertEquals(data.getKey(1), "B");
    10
    assertEquals(data.getKey(3), "B");
    Differences
    Expression1Expression2Difference
    13LITERAL_VALUE_MISMATCH
    10
    assertEquals(data.getKey(3), "B");
    9
    assertEquals(data.getKey(2), "C");
    9
    assertEquals(data.getKey(2), "C");
    7
    assertEquals(data.getKey(0), "C");
    Differences
    Expression1Expression2Difference
    20LITERAL_VALUE_MISMATCH
    7
    assertEquals(data.getKey(0), "C");
    10
    assertEquals(data.getKey(3), "D");
    10
    assertEquals(data.getKey(3), "D");
    9
    assertEquals(data.getKey(2), "D");
    Differences
    Expression1Expression2Difference
    32LITERAL_VALUE_MISMATCH
    9
    assertEquals(data.getKey(2), "D");
    11
    assertEquals(data.getValue("A"), new Double(2.0));
    11
    assertEquals(data.getValue("A"), new Double(2.0));
    12
    assertEquals(data.getValue("B"), null);
    12
    assertEquals(data.getValue("B"), null);
    13
    assertEquals(data.getValue("C"), new Double(1.0));
    13
    assertEquals(data.getValue("C"), new Double(1.0));
    14
    assertEquals(data.getValue("D"), new Double(3.0));
    14
    assertEquals(data.getValue("D"), new Double(3.0));
    15
    assertEquals(data.getValue(0), new Double(2.0));
    15
    assertEquals(data.getValue(0), new Double(2.0));
    16
    assertEquals(data.getValue(1), new Double(2.0));
    Differences
    Expression1Expression2Difference
    01LITERAL_VALUE_MISMATCH
    16
    assertEquals(data.getValue(1), new Double(2.0));
    16
    assertEquals(data.getValue(1), null);
    16
    assertEquals(data.getValue(1), null);
    18
    assertEquals(data.getValue(3), null);
    Differences
    Expression1Expression2Difference
    13LITERAL_VALUE_MISMATCH
    18
    assertEquals(data.getValue(3), null);
    17
    assertEquals(data.getValue(2), new Double(1.0));
    17
    assertEquals(data.getValue(2), new Double(1.0));
    15
    assertEquals(data.getValue(0), new Double(1.0));
    Differences
    Expression1Expression2Difference
    20LITERAL_VALUE_MISMATCH
    15
    assertEquals(data.getValue(0), new Double(1.0));
    18
    assertEquals(data.getValue(3), new Double(3.0));
    18
    assertEquals(data.getValue(3), new Double(3.0));
    17
    assertEquals(data.getValue(2), new Double(3.0));
    Differences
    Expression1Expression2Difference
    32LITERAL_VALUE_MISMATCH
    17
    assertEquals(data.getValue(2), new Double(3.0));
    Precondition Violations (4)
    Row Violation
    1Expression data.sortByKeys(SortOrder.ASCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression data.sortByValues(SortOrder.ASCENDING) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression data.sortByKeys(SortOrder.ASCENDING) is a void method call, and thus it cannot be parameterized
    4Expression data.sortByValues(SortOrder.ASCENDING) is a void method call, and thus it cannot be parameterized