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.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: 21 Number of AST nodes: 21
1
if (dataset.getDomainOrder() == DomainOrder.DESCENDING) {
1
if (dataset.getDomainOrder() == DomainOrder.DESCENDING) {
2
            // when the x-values are sorted in descending order, the lower
2
            // when the x-values are descending
3
            // bound is found by calculating relative to the xHigh value
3
, the upper bound is found by
4
            // comparing against xLow
4
            int low = 0;
5
            int low = 0;
5
            int high = itemCount - 1;
6
            int high = itemCount - 1;
6
            int mid = (low + high) / 2;
7
            int mid = (low + high) / 2;
7
            double lowValue = dataset.getXValue(series, low);
8
            double lowValue = dataset.getXValue(series, low);
8
            if (lowValue <= xHigh) {
9
            if (lowValue < xLow) {
9
                return low;
10
                return low;
10
            }
11
            }
11
            double highValue = dataset.getXValue(series, high);
12
            double highValue = dataset.getXValue(series, high);
12
            if (highValue > xHigh) {
13
            if (highValue >= xLow) {
13
                return high;
14
                return high;
14
            }
15
            }
15
            while (high - low > 1) {
16
            while (high - low > 1) {
16
                double midV = dataset.getXValue(series, mid);
17
                double midV = dataset.getXValue(series, mid);
17
                if (midV > xHigh) {
18
                if (midV >= xLow) {
18
                    low = mid;
19
                    low = mid;
19
                }
20
                }
20
                else {
21
                else {
21
                    high = mid;
22
                    high = mid;
22
                }
23
                }
23
                mid = (low + high) / 2;
24
                mid = (low + high) / 2;
24
            }
25
            }
25
            return mid;
26
            return mid;
26
        }
27
        }
27
        else {
28
        else {
28
            // we don't know anything about the ordering of the x-values,
29
            // we don't know anything about the ordering of the x-values,
29
            // but we can still skip any initial values that fall outside the
30
            // but we can still skip any trailing values that fall outside the
30
            // range...
31
            // range...
31
            int index = 0;
32
            int index = itemCount - 1;
32
            // skip any items that don't need including...
33
            // skip any items that don't need including...
33
            while (index < itemCount && dataset.getXValue(series, index) 
34
            while (index >= 0 && dataset.getXValue(series, index) 
34
                    < xLow) {
35
                    > xHigh) {
35
                index++;
36
                index--;
36
            }
37
            }
37
            return Math.max(0, index - 1);
38
            return Math.min(itemCount - 1, index + 1);
38
        }
39
        }
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.5
Clones locationClones are declared in the same class
Number of node comparisons4