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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 2.8 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 220 |
Number of mapped statements | 34 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 4 |
Time elapsed for statement mapping (ms) | 17.6 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | if (dataset.getDomainOrder() == DomainOrder.ASCENDING) |
| 21 | if (dataset.getDomainOrder() == DomainOrder.DESCENDING) | ||||||||||||
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) |
| 26 | if (lowValue < xLow) | ||||||||||||
10 | return low; | 27 | return low; | |||||||||||||
11 | double highValue = dataset.getXValue(series, high); | 28 | double highValue = dataset.getXValue(series, high); | |||||||||||||
12 | if (highValue < xLow) |
| 29 | if (highValue >= xLow) | ||||||||||||
13 | return high; | 30 | return high; | |||||||||||||
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; |
| 34 | low = mid; | ||||||||||||
else | else | |||||||||||||||
18 | low = mid; |
| 35 | high = mid; | ||||||||||||
19 | mid = (low + high) / 2; | 36 | mid = (low + high) / 2; | |||||||||||||
20 | return mid; | 37 | return mid; | |||||||||||||
21 | else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) |
| 4 | else if (dataset.getDomainOrder() == DomainOrder.ASCENDING) | ||||||||||||
22 | int low = 0; | 5 | int low = 0; | |||||||||||||
23 | int high = itemCount - 1; | 6 | int high = itemCount - 1; | |||||||||||||
24 | int mid = (low + high) / 2; |
| 7 | int mid = (low + high + 1) / 2; | ||||||||||||
25 | double lowValue = dataset.getXValue(series, low); | 8 | double lowValue = dataset.getXValue(series, low); | |||||||||||||
26 | if (lowValue <= xHigh) |
| 9 | if (lowValue > xHigh) | ||||||||||||
27 | return low; | 10 | return low; | |||||||||||||
28 | double highValue = dataset.getXValue(series, high); | 11 | double highValue = dataset.getXValue(series, high); | |||||||||||||
29 | if (highValue > xHigh) |
| 12 | if (highValue <= xHigh) | ||||||||||||
30 | return high; | 13 | return high; | |||||||||||||
31 | while (high - low > 1) | 14 | while (high - low > 1) | |||||||||||||
32 | double midV = dataset.getXValue(series, mid); | 15 | double midV = dataset.getXValue(series, mid); | |||||||||||||
33 | if (midV > xHigh) |
| 16 | if (midV <= xHigh) | ||||||||||||
34 | low = mid; | 17 | low = mid; | |||||||||||||
else | else | |||||||||||||||
35 | high = mid; | 18 | high = mid; | |||||||||||||
36 | mid = (low + high) / 2; |
| 19 | mid = (low + high + 1) / 2; | ||||||||||||
37 | return mid; | 20 | return mid; | |||||||||||||
else | | |||||||||||||||
| 38 | int index = itemCount - 1; | ||||||||||||||
38 | int index = 0; | | ||||||||||||||
|
| 39 | while (index >= 0 && dataset.getXValue(series, index) > xHigh) | |||||||||||||
| 40 | index--; | ||||||||||||||
39 | while (index < itemCount && dataset.getXValue(series, index) < xLow) |
| | |||||||||||||
40 | index++; | | ||||||||||||||
|
| 41 | return Math.min(itemCount - 1, index + 1); | |||||||||||||
41 | return Math.max(0, index - 1); |
| |
Row | Violation |
---|---|
1 | Expression lowValue >= xLow cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression lowValue < xLow cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression highValue < xLow cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression highValue >= xLow cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression low cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression high cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression low + high cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression low + high + 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression lowValue <= xHigh cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression lowValue > xHigh cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression highValue > xHigh cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression highValue <= xHigh cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression midV > xHigh cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression midV <= xHigh cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression low + high cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression low + high + 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement while(index >= 0 && dataset.getXValue(series,index) > xHigh) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
20 | Unmatched statement while(index >= 0 && dataset.getXValue(series,index) > xHigh) cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
21 | Unmatched statement while(index < itemCount && dataset.getXValue(series,index) < xLow) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
22 | Unmatched statement while(index < itemCount && dataset.getXValue(series,index) < xLow) cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
23 | Unmatched return Math.min(itemCount - 1,index + 1); |
24 | Unmatched return Math.max(0,index - 1); |
25 | Not all possible execution flows end in a return statement |