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