protected class EIterator<E1> implements Iterator<E1> { /** * The current position of the iterator. */ protected int cursor = 0; /** * The previous position of the iterator. */ protected int lastCursor = -1; /** * The modification count of the containing list. */ protected int expectedModCount = modCount; /** * Returns whether there are more objects. * @return whether there are more objects. */ public boolean hasNext() { return cursor != size(); } /** * Returns the next object and advances the iterator. * This implementation delegates to {@link #doNext doNext}. * @return the next object. * @exception NoSuchElementException if the iterator is done. */ @SuppressWarnings("unchecked") public E1 next() { return (E1)doNext(); } /** * Returns the next object and advances the iterator. * This implementation delegates to {@link BasicEList#get get}. * @return the next object. * @exception NoSuchElementException if the iterator is done. */ protected E doNext() { try { E next = BasicEList.this.get(cursor); checkModCount(); lastCursor = cursor++; return next; } catch (IndexOutOfBoundsException exception) { checkModCount(); throw new NoSuchElementException(); } } /** * Removes the last object returned by {@link #next()} from the list, * it's an optional operation. * This implementation can also function in a list iterator * to act upon on the object returned by calling <code>previous</code>. * @exception IllegalStateException * if <code>next</code> has not yet been called, * or <code>remove</code> has already been called after the last call to <code>next</code>. */ public void remove() { if (lastCursor == -1) { throw new IllegalStateException(); } checkModCount(); try { BasicEList.this.remove(lastCursor); expectedModCount = modCount; if (lastCursor < cursor) { --cursor; } lastCursor = -1; } catch (IndexOutOfBoundsException exception) { throw new ConcurrentModificationException(); } } /** * Checks that the modification count is as expected. * @exception ConcurrentModificationException if the modification count is not as expected. */ protected void checkModCount() { if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } } } /** * Returns a read-only iterator that does not {@link #resolve resolve} objects. * This implementation allocates a {@link NonResolvingEIterator}. * @return a read-only iterator that does not resolve objects. */ protected Iterator<E> basicIterator() { return new NonResolvingEIterator<E>();
protected class EIterator<E1> implements Iterator<E1> { /** * The current position of the iterator. */ protected int cursor = 0; /** * The previous position of the iterator. */ protected int lastCursor = -1; /** * The modification count of the containing list. */ protected int expectedModCount = modCount; /** * Returns whether there are more objects. * @return whether there are more objects. */ public boolean hasNext() { return cursor != size(); } /** * Returns the next object and advances the iterator. * This implementation delegates to {@link #doNext doNext}. * @return the next object. * @exception NoSuchElementException if the iterator is done. */ @SuppressWarnings("unchecked") public E1 next() { return (E1)doNext(); } /** * Returns the next object and advances the iterator. * This implementation delegates to {@link DelegatingEList#get get}. * @return the next object. * @exception NoSuchElementException if the iterator is done. */ protected E doNext() { try { E next = DelegatingEList.this.get(cursor); checkModCount(); lastCursor = cursor++; return next; } catch (IndexOutOfBoundsException exception) { checkModCount(); throw new NoSuchElementException(); } } /** * Removes the last object returned by {@link #next()} from the list, * it's an optional operation. * This implementation can also function in a list iterator * to act upon on the object returned by calling <code>previous</code>. * @exception IllegalStateException * if <code>next</code> has not yet been called, * or <code>remove</code> has already been called after the last call to <code>next</code>. */ public void remove() { if (lastCursor == -1) { throw new IllegalStateException(); } checkModCount(); try { DelegatingEList.this.remove(lastCursor); expectedModCount = modCount; if (lastCursor < cursor) { --cursor; } lastCursor = -1; } catch (IndexOutOfBoundsException exception) { throw new ConcurrentModificationException(); } } /** * Checks that the modification count is as expected. * @exception ConcurrentModificationException if the modification count is not as expected. */ protected void checkModCount() { if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } } } /** * Returns a read-only iterator that does not {@link #resolve resolve} objects. * This implementation allocates a {@link NonResolvingEIterator}. * @return a read-only iterator that does not resolve objects. */ protected Iterator<E> basicIterator() { return new NonResolvingEIterator<E>();
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/common/util/BasicEList.java File path: /emf-2.4.1/src/org/eclipse/emf/common/util/DelegatingEList.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
protected class EIterator<E1> implements Iterator<E1>
1
protected class EIterator<E1> implements Iterator<E1>
2
  {
2
  {
3
    /**
3
    /**
4
     * The current position of the iterator.
4
     * The current position of the iterator.
5
     */
5
     */
6
    protected int cursor = 0;
6
    protected int cursor = 0;
7
    /**
7
    /**
8
     * The previous position of the iterator.
8
     * The previous position of the iterator.
9
     */
9
     */
10
    protected int lastCursor = -1;
10
    protected int lastCursor = -1;
11
    /**
11
    /**
12
     * The modification count of the containing list.
12
     * The modification count of the containing list.
13
     */
13
     */
14
    protected int expectedModCount = modCount;
14
    protected int expectedModCount = modCount;
15
    /**
15
    /**
16
     * Returns whether there are more objects.
16
     * Returns whether there are more objects.
17
     * @return whether there are more objects.
17
     * @return whether there are more objects.
18
     */
18
     */
19
    public boolean hasNext() 
19
    public boolean hasNext() 
20
    {
20
    {
21
      return cursor != size();
21
      return cursor != size();
22
    }
22
    }
23
    /**
23
    /**
24
     * Returns the next object and advances the iterator.
24
     * Returns the next object and advances the iterator.
25
     * This implementation delegates to {@link #doNext doNext}.
25
     * This implementation delegates to {@link #doNext doNext}.
26
     * @return the next object.
26
     * @return the next object.
27
     * @exception NoSuchElementException if the iterator is done.
27
     * @exception NoSuchElementException if the iterator is done.
28
     */
28
     */
29
    @SuppressWarnings("unchecked")
29
    @SuppressWarnings("unchecked")
30
    public E1 next() 
30
    public E1 next() 
31
    {
31
    {
32
      return (E1)doNext();
32
      return (E1)doNext();
33
    }
33
    }
34
    /**
34
    /**
35
     * Returns the next object and advances the iterator.
35
     * Returns the next object and advances the iterator.
36
     * This implementation delegates to {@link BasicEList#get get}.
36
     * This implementation delegates to {@link DelegatingEList#get get}.
37
     * @return the next object.
37
     * @return the next object.
38
     * @exception NoSuchElementException if the iterator is done.
38
     * @exception NoSuchElementException if the iterator is done.
39
     */
39
     */
40
    protected E doNext() 
40
    protected E doNext() 
41
    {
41
    {
42
      try 
42
      try 
43
      {
43
      {
44
        E next = BasicEList.this.get(cursor);
44
        E next = DelegatingEList.this.get(cursor);
45
        checkModCount();
45
        checkModCount();
46
        lastCursor = cursor++;
46
        lastCursor = cursor++;
47
        return next;
47
        return next;
48
      } 
48
      } 
49
      catch (IndexOutOfBoundsException exception) 
49
      catch (IndexOutOfBoundsException exception) 
50
      {
50
      {
51
        checkModCount();
51
        checkModCount();
52
        throw new NoSuchElementException();
52
        throw new NoSuchElementException();
53
      }
53
      }
54
    }
54
    }
55
    /**
55
    /**
56
     * Removes the last object returned by {@link #next()} from the list,
56
     * Removes the last object returned by {@link #next()} from the list,
57
     * it's an optional operation.
57
     * it's an optional operation.
58
     * This implementation can also function in a list iterator 
58
     * This implementation can also function in a list iterator 
59
     * to act upon on the object returned by calling <code>previous</code>.
59
     * to act upon on the object returned by calling <code>previous</code>.
60
     * @exception IllegalStateException
60
     * @exception IllegalStateException
61
     * if <code>next</code> has not yet been called,
61
     * if <code>next</code> has not yet been called,
62
     * or <code>remove</code> has already been called after the last call to <code>next</code>.
62
     * or <code>remove</code> has already been called after the last call to <code>next</code>.
63
     */
63
     */
64
    public void remove() 
64
    public void remove() 
65
    {
65
    {
66
      if (lastCursor == -1)
66
      if (lastCursor == -1)
67
      {
67
      {
68
        throw new IllegalStateException();
68
        throw new IllegalStateException();
69
      }
69
      }
70
      checkModCount();
70
      checkModCount();
71
      try 
71
      try 
72
      {
72
      {
73
        BasicEList.this.remove(lastCursor);
73
        DelegatingEList.this.remove(lastCursor);
74
        expectedModCount = modCount;
74
        expectedModCount = modCount;
75
        if (lastCursor < cursor)
75
        if (lastCursor < cursor)
76
        {
76
        {
77
          --cursor;
77
          --cursor;
78
        }
78
        }
79
        lastCursor = -1;
79
        lastCursor = -1;
80
      } 
80
      } 
81
      catch (IndexOutOfBoundsException exception) 
81
      catch (IndexOutOfBoundsException exception) 
82
      {
82
      {
83
        throw new ConcurrentModificationException();
83
        throw new ConcurrentModificationException();
84
      }
84
      }
85
    }
85
    }
86
    /**
86
    /**
87
     * Checks that the modification count is as expected.
87
     * Checks that the modification count is as expected.
88
     * @exception ConcurrentModificationException if the modification count is not as expected.
88
     * @exception ConcurrentModificationException if the modification count is not as expected.
89
     */
89
     */
90
    protected void checkModCount() 
90
    protected void checkModCount() 
91
    {
91
    {
92
      if (modCount != expectedModCount)
92
      if (modCount != expectedModCount)
93
      {
93
      {
94
        throw new ConcurrentModificationException();
94
        throw new ConcurrentModificationException();
95
      }
95
      }
96
    }
96
    }
97
  }
97
  }
98
  /**
98
  /**
99
   * Returns a read-only iterator that does not {@link #resolve resolve} objects.
99
   * Returns a read-only iterator that does not {@link #resolve resolve} objects.
100
   * This implementation allocates a {@link NonResolvingEIterator}.
100
   * This implementation allocates a {@link NonResolvingEIterator}.
101
   * @return a read-only iterator that does not resolve objects.
101
   * @return a read-only iterator that does not resolve objects.
102
   */
102
   */
103
  protected Iterator<E> basicIterator()
103
  protected Iterator<E> basicIterator()
104
  {
104
  {
105
    return new NonResolvingEIterator<E>();
105
    return new NonResolvingEIterator<E>();
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.0
Clones location
Number of node comparisons0