125-1-2

protected void add(ComparableObjectItem item, boolean notify) { if (item == null) { throw new IllegalArgumentException("Null 'item' argument."); } if (this.autoSort) { int index = Collections.binarySearch(this.data, item); if (index < 0) { this.data.add(-index - 1, item); } else { if (this.allowDuplicateXValues) { // need to make sure we are adding *after* any duplicates int size = this.data.size(); while (index < size && item.compareTo(this.data.get(index)) == 0) { index++; } if (index < this.data.size()) { this.data.add(index, item); } else { this.data.add(item); } } else { throw new SeriesException("X-value already exists."); } } } else { if (!this.allowDuplicateXValues) { // can't allow duplicate values, so we need to check whether // there is an item with the given x-value already int index = indexOf(item.getComparable()); if (index >= 0) { throw new SeriesException("X-value already exists."); } } this.data.add(item); } if (getItemCount() > this.maximumItemCount) { this.data.remove(0); } if (notify) { fireSeriesChanged();
public void add(XYDataItem item, boolean notify) { if (item == null) { throw new IllegalArgumentException("Null 'item' argument."); } if (this.autoSort) { int index = Collections.binarySearch(this.data, item); if (index < 0) { this.data.add(-index - 1, item); } else { if (this.allowDuplicateXValues) { // need to make sure we are adding *after* any duplicates int size = this.data.size(); while (index < size && item.compareTo(this.data.get(index)) == 0) { index++; } if (index < this.data.size()) { this.data.add(index, item); } else { this.data.add(item); } } else { throw new SeriesException("X-value already exists."); } } } else { if (!this.allowDuplicateXValues) { // can't allow duplicate values, so we need to check whether // there is an item with the given x-value already int index = indexOf(item.getX()); if (index >= 0) { throw new SeriesException("X-value already exists."); } } this.data.add(item); } if (getItemCount() > this.maximumItemCount) { this.data.remove(0); } if (notify) { fireSeriesChanged();

Clone fragments detected by clone detection tool
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: `` |  | Method name: ``
Number of AST nodes: 0 |  | Number of AST nodes: 0

1

    protected void add(ComparableObjectItem item, boolean notify) {↵

1

    public void add(XYDataItem item, boolean notify) {↵

2

            if (item == null) {↵

2

            if (item == null) {↵

3

                throw new IllegalArgumentException("Null 'item' argument.");↵

3

                throw new IllegalArgumentException("Null 'item' argument.");↵

4

            }↵

4

            }↵

5

            if (this.autoSort) {↵

5

            if (this.autoSort) {↵

6

                int index = Collections.binarySearch(this.data, item);↵

6

                int index = Collections.binarySearch(this.data, item);↵

7

                if (index < 0) {↵

7

                if (index < 0) {↵

8

                    this.data.add(-index - 1, item);↵

8

                    this.data.add(-index - 1, item);↵

9

                }↵

9

                }↵

10

                else {↵

10

                else {↵

11

                    if (this.allowDuplicateXValues) {↵

11

                    if (this.allowDuplicateXValues) {↵

12

                        // need to make sure we are adding *after* any duplicates↵

12

                        // need to make sure we are adding *after* any duplicates↵

13

                        int size = this.data.size();↵

13

                        int size = this.data.size();↵

14

                        while (index < size ↵

14

                        while (index < size↵

15

                               && item.compareTo(this.data.get(index)) == 0) {↵

15

                               && item.compareTo(this.data.get(index)) == 0) {↵

16

                            index++;↵

16

                            index++;↵

17

                        }↵

17

                        }↵

18

                        if (index < this.data.size()) {↵

18

                        if (index < this.data.size()) {↵

19

                            this.data.add(index, item);↵

19

                            this.data.add(index, item);↵

20

                        }↵

20

                        }↵

21

                        else {↵

21

                        else {↵

22

                            this.data.add(item);↵

22

                            this.data.add(item);↵

23

                        }↵

23

                        }↵

24

                    }↵

24

                    }↵

25

                    else {↵

25

                    else {↵

26

                        throw new SeriesException("X-value already exists.");↵

26

                        throw new SeriesException("X-value already exists.");↵

27

                    }↵

27

                    }↵

28

                }↵

28

                }↵

29

            }↵

29

            }↵

30

            else {↵

30

            else {↵

31

                if (!this.allowDuplicateXValues) {↵

31

                if (!this.allowDuplicateXValues) {↵

32

                    // can't allow duplicate values, so we need to check whether↵

32

                    // can't allow duplicate values, so we need to check whether↵

33

                    // there is an item with the given x-value already↵

33

                    // there is an item with the given x-value already↵

34

                    int index = indexOf(item.getComparable());↵

34

                    int index = indexOf(item.getX());↵

35

                    if (index >= 0) {↵

35

                    if (index >= 0) {↵

36

                        throw new SeriesException("X-value already exists.");      ↵

36

                        throw new SeriesException("X-value already exists.");↵

37

                    }↵

37

                    }↵

38

                }↵

38

                }↵

39

                this.data.add(item);↵

39

                this.data.add(item);↵

40

            }↵

40

            }↵

41

            if (getItemCount() > this.maximumItemCount) {↵

41

            if (getItemCount() > this.maximumItemCount) {↵

42

                this.data.remove(0);↵

42

                this.data.remove(0);↵

43

            }                    ↵

43

            }↵

44

            if (notify) {↵

44

            if (notify) {↵

45

                fireSeriesChanged();↵

45

                fireSeriesChanged();↵

46

46

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 0
Number of refactorable cases | 0
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0
Clones location |
Number of node comparisons | 0