if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { // for data in ascending order by x-value, we are (broadly) looking // for the index of the highest x-value that is less that xLow int low = 0; int high = itemCount - 1; int mid = (low + high) / 2; double lowValue = dataset.getXValue(series, low); if (lowValue >= xLow) { // special case where the lowest x-value is >= xLow return low; } double highValue = dataset.getXValue(series, high); if (highValue < xLow) { // special case where the highest x-value is < xLow return high; } while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (midV >= xLow) { high = mid; } else { low = mid; } mid = (low + high) / 2; } return mid; } else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { // when the x-values are sorted in descending order, the lower // bound is found by calculating relative to the xHigh value int low = 0; int high = itemCount - 1; int mid = (low + high) / 2; double lowValue = dataset.getXValue(series, low); if (lowValue <= xHigh) { return low; } double highValue = dataset.getXValue(series, high); if (highValue > xHigh) { return high; } while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (midV > xHigh) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return mid; } else { // we don't know anything about the ordering of the x-values, // but we can still skip any initial values that fall outside the // range... int index = 0; // skip any items that don't need including... while (index < itemCount && dataset.getXValue(series, index) < xLow) { index++; } return Math.max(0, index - 1); }
if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { int low = 0; int high = itemCount - 1; int mid = (low + high + 1) / 2; double lowValue = dataset.getXValue(series, low); if (lowValue > xHigh) { return low; } double highValue = dataset.getXValue(series, high); if (highValue <= xHigh) { return high; } while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (midV <= xHigh) { low = mid; } else { high = mid; } mid = (low + high + 1) / 2; } return mid; } else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { // when the x-values are descending, the upper bound is found by // comparing against xLow int low = 0; int high = itemCount - 1; int mid = (low + high) / 2; double lowValue = dataset.getXValue(series, low); if (lowValue < xLow) { return low; } double highValue = dataset.getXValue(series, high); if (highValue >= xLow) { return high; } while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (midV >= xLow) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return mid; } else { // we don't know anything about the ordering of the x-values, // but we can still skip any trailing values that fall outside the // range... int index = itemCount - 1; // skip any items that don't need including... while (index >= 0 && dataset.getXValue(series, index) > xHigh) { index--; } return Math.min(itemCount - 1, index + 1); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/RendererUtilities.java File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/RendererUtilities.java
Method name: int findLiveItemsLowerBound(XYDataset, int, double, double) Method name: int findLiveItemsUpperBound(XYDataset, int, double, double)
Number of AST nodes: 38 Number of AST nodes: 38
1
if (dataset.getDomainOrder() == DomainOrder.ASCENDING) {
1
if (dataset.getDomainOrder() == DomainOrder.ASCENDING) {
2
            // for data in ascending order by x-value, we are (broadly) looking
3
            // for the index of the highest x-value that is less that xLow
4
            int low = 0;
2
            int low = 0;
5
            int high = itemCount - 1;
3
            int high = itemCount - 1;
6
            int mid = (low + high) / 2;
4
            int mid = (low + high + 1) / 2;
7
            double lowValue = dataset.getXValue(series, low);
5
            double lowValue = dataset.getXValue(series, low);
8
            if (lowValue >= xLow) {
6
            if (lowValue > xHigh) {
9
                // special case where the lowest x-value is >= xLow
10
                return low;
7
                return low;
11
            }
8
            }
12
            double highValue = dataset.getXValue(series, high);
9
            double highValue = dataset.getXValue(series, high);
13
            if (highValue < xLow) {
10
            if (highValue <= x
14
                // special case where the highest x-value is < xLow
11
High) {
15
                return high;
12
                return high;
16
            }
13
            }
17
            while (high - low > 1) {
14
            while (high - low > 1) {
18
                double midV = dataset.getXValue(series, mid);
15
                double midV = dataset.getXValue(series, mid);
19
                if (midV >= xLow) {
16
                if (midV <= xHigh) {
20
                    high = mid;
17
                    low = mid;
21
                }
18
                }
22
                else {
19
                else {
23
                    low = mid;
20
                    high = mid;
24
                }
21
                }
25
                mid = (low + high) / 2;
22
                mid = (low + high + 1) / 2;
26
            }
23
            }
27
            return mid;
24
            return mid;
28
        }
25
        }
29
        else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) {
26
        else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) {
30
            // when the x-values are sorted in descending order, the lower
27
            // when the x-values are descending
31
            // bound is found by calculating relative to the xHigh value
28
, the upper bound is found by
29
            // comparing against xLow
32
            int low = 0;
30
            int low = 0;
33
            int high = itemCount - 1;
31
            int high = itemCount - 1;
34
            int mid = (low + high) / 2;
32
            int mid = (low + high) / 2;
35
            double lowValue = dataset.getXValue(series, low);
33
            double lowValue = dataset.getXValue(series, low);
36
            if (lowValue <= xHigh) {
34
            if (lowValue < xLow) {
37
                return low;
35
                return low;
38
            }
36
            }
39
            double highValue = dataset.getXValue(series, high);
37
            double highValue = dataset.getXValue(series, high);
40
            if (highValue > xHigh) {
38
            if (highValue >= xLow) {
41
                return high;
39
                return high;
42
            }
40
            }
43
            while (high - low > 1) {
41
            while (high - low > 1) {
44
                double midV = dataset.getXValue(series, mid);
42
                double midV = dataset.getXValue(series, mid);
45
                if (midV > xHigh) {
43
                if (midV >= xLow) {
46
                    low = mid;
44
                    low = mid;
47
                }
45
                }
48
                else {
46
                else {
49
                    high = mid;
47
                    high = mid;
50
                }
48
                }
51
                mid = (low + high) / 2;
49
                mid = (low + high) / 2;
52
            }
50
            }
53
            return mid;
51
            return mid;
54
        }
52
        }
55
        else {
53
        else {
56
            // we don't know anything about the ordering of the x-values,
54
            // we don't know anything about the ordering of the x-values,
57
            // but we can still skip any initial values that fall outside the
55
            // but we can still skip any trailing values that fall outside the
58
            // range...
56
            // range...
59
            int index = 0;
57
            int index = itemCount - 1;
60
            // skip any items that don't need including...
58
            // skip any items that don't need including...
61
            while (index < itemCount && dataset.getXValue(series, index) 
59
            while (index >= 0 && dataset.getXValue(series, index) 
62
                    < xLow) {
60
                    > xHigh) {
63
                index++;
61
                index--;
64
            }
62
            }
65
            return Math.max(0, index - 1);
63
            return Math.min(itemCount - 1, index + 1);
66
        }
64
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)1.9
Clones locationClones are declared in the same class
Number of node comparisons88
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)5.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    int low = 0;
    22
    int low = 0;
    6
    int high = itemCount - 1;
    23
    int high = itemCount - 1;
    7
    int mid = (low + high) / 2;
    24
    int mid = (low + high) / 2;
    8
    double lowValue = dataset.getXValue(series, low);
    25
    double lowValue = dataset.getXValue(series, low);
    9
    if (lowValue >= xLow)
    9
    if (lowValue >= xLow)
    29
    if (highValue >= xLow)
    Differences
    Expression1Expression2Difference
    lowValuehighValueVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression lowValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression highValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29
    if (highValue >= xLow)
    10
    return low;
    10
    return low;
    30
    return high;
    Differences
    Expression1Expression2Difference
    lowhighVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30
    return high;
    11
    double highValue = dataset.getXValue(series, high);
    28
    double highValue = dataset.getXValue(series, high);
    12
    if (highValue < xLow)
    12
    if (highValue < xLow)
    26
    if (lowValue < xLow)
    Differences
    Expression1Expression2Difference
    highValuelowValueVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression highValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression lowValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26
    if (lowValue < xLow)
    13
    return high;
    13
    return high;
    27
    return low;
    Differences
    Expression1Expression2Difference
    highlowVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27
    return low;
    14
    while (high - low > 1)
    31
    while (high - low > 1)
    15
    double midV = dataset.getXValue(series, mid);
    32
    double midV = dataset.getXValue(series, mid);
    16
    if (midV >= xLow)
    33
    if (midV >= xLow)
    17
    high = mid;
    17
    high = mid;
    34
    low = mid;
    Differences
    Expression1Expression2Difference
    highlowVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    34
    low = mid;
    else
    else
    18
    low = mid;
    18
    low = mid;
    35
    high = mid;
    Differences
    Expression1Expression2Difference
    lowhighVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted
    35
    high = mid;
    19
    mid = (low + high) / 2;
    36
    mid = (low + high) / 2;
    Precondition Violations (12)
    Row Violation
    1Expression lowValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression highValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression highValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression lowValue cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted