File path: /jfreechart-1.0.10/src/org/jfree/data/ComparableObjectSeries.java | File path: /jfreechart-1.0.10/src/org/jfree/data/xy/XYSeries.java | |||
Method name: void add(ComparableObjectItem, boolean)
|
Method name: void add(XYDataItem, boolean)
|
|||
Number of AST nodes: 17 | Number of AST nodes: 17 | |||
1 | if (this.autoSort) {↵ | 1 | if (this.autoSort) {↵ | |
2 | int index = Collections.binarySearch(this.data, item);↵ | 2 | int index = Collections.binarySearch(this.data, item);↵ | |
3 | if (index < 0) {↵ | 3 | if (index < 0) {↵ | |
4 | this.data.add(-index - 1, item);↵ | 4 | this.data.add(-index - 1, item);↵ | |
5 | }↵ | 5 | }↵ | |
6 | else {↵ | 6 | else {↵ | |
7 | if (this.allowDuplicateXValues) {↵ | 7 | if (this.allowDuplicateXValues) {↵ | |
8 | // need to make sure we are adding *after* any duplicates↵ | 8 | // need to make sure we are adding *after* any duplicates↵ | |
9 | int size = this.data.size();↵ | 9 | int size = this.data.size();↵ | |
10 | while (index < size ↵ | 10 | while (index < size↵ | |
11 | && item.compareTo(this.data.get(index)) == 0) {↵ | 11 | && item.compareTo(this.data.get(index)) == 0) {↵ | |
12 | index++;↵ | 12 | index++;↵ | |
13 | }↵ | 13 | }↵ | |
14 | if (index < this.data.size()) {↵ | 14 | if (index < this.data.size()) {↵ | |
15 | this.data.add(index, item);↵ | 15 | this.data.add(index, item);↵ | |
16 | }↵ | 16 | }↵ | |
17 | else {↵ | 17 | else {↵ | |
18 | this.data.add(item);↵ | 18 | this.data.add(item);↵ | |
19 | }↵ | 19 | }↵ | |
20 | }↵ | 20 | }↵ | |
21 | else {↵ | 21 | else {↵ | |
22 | throw new SeriesException("X-value already exists.");↵ | 22 | throw new SeriesException("X-value already exists.");↵ | |
23 | }↵ | 23 | }↵ | |
24 | }↵ | 24 | }↵ | |
25 | }↵ | 25 | }↵ | |
26 | else {↵ | 26 | else {↵ | |
27 | if (!this.allowDuplicateXValues) {↵ | 27 | if (!this.allowDuplicateXValues) {↵ | |
28 | // can't allow duplicate values, so we need to check whether↵ | 28 | // can't allow duplicate values, so we need to check whether↵ | |
29 | // there is an item with the given x-value already↵ | 29 | // there is an item with the given x-value already↵ | |
30 | int index = indexOf(item.getComparable());↵ | 30 | int index = indexOf(item.getX());↵ | |
31 | if (index >= 0) {↵ | 31 | if (index >= 0) {↵ | |
32 | throw new SeriesException("X-value already exists."); ↵ | 32 | throw new SeriesException("X-value already exists.");↵ | |
33 | }↵ | 33 | }↵ | |
34 | }↵ | 34 | }↵ | |
35 | this.data.add(item);↵ | 35 | this.data.add(item);↵ | |
36 | } | 36 |
| |
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.3 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 54 |
Number of mapped statements | 16 |
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) | 6.8 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | if (this.autoSort) | 3 | if (this.autoSort) | ||||||||||||
4 | int index = Collections.binarySearch(this.data, item); |
| 4 | int index = Collections.binarySearch(this.data, item); | |||||||||||
5 | if (index < 0) | 5 | if (index < 0) | ||||||||||||
6 | this.data.add(-index - 1, item); |
| 6 | this.data.add(-index - 1, item); | |||||||||||
else | else | ||||||||||||||
7 | if (this.allowDuplicateXValues) | 7 | if (this.allowDuplicateXValues) | ||||||||||||
8 | int size = this.data.size(); | 8 | int size = this.data.size(); | ||||||||||||
9 | while (index < size && item.compareTo(this.data.get(index)) == 0) |
| 9 | while (index < size && item.compareTo(this.data.get(index)) == 0) | |||||||||||
10 | index++; | 10 | index++; | ||||||||||||
11 | if (index < this.data.size()) | 11 | if (index < this.data.size()) | ||||||||||||
12 | this.data.add(index, item); |
| 12 | this.data.add(index, item); | |||||||||||
else | else | ||||||||||||||
13 | this.data.add(item); |
| 13 | this.data.add(item); | |||||||||||
else | else | ||||||||||||||
14 | throw new SeriesException("X-value already exists."); | 14 | throw new SeriesException("X-value already exists."); | ||||||||||||
else | else | ||||||||||||||
15 | if (!this.allowDuplicateXValues) | 15 | if (!this.allowDuplicateXValues) | ||||||||||||
| 16 | int index = indexOf(item.getX()); | |||||||||||||
16 | int index = indexOf(item.getComparable()); | | |||||||||||||
17 | if (index >= 0) | 17 | if (index >= 0) | ||||||||||||
18 | throw new SeriesException("X-value already exists."); | 18 | throw new SeriesException("X-value already exists."); | ||||||||||||
19 | this.data.add(item); |
| 19 | this.data.add(item); |
Row | Violation |
---|---|
1 | Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item |
2 | Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item |
3 | Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item |
4 | Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item |
5 | Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item |
6 | Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item |