protected class EListIterator<E1> extends EIterator<E1> implements ListIterator<E1> { /** * Creates an instance. */ public EListIterator() { super(); } /** * Creates an instance advanced to the index. * @param index the starting index. */ public EListIterator(int index) { cursor = index; } /** * Returns whether there are more objects for {@link #previous}. * Returns whether there are more objects. */ public boolean hasPrevious() { return cursor != 0; } /** * Returns the previous object and advances the iterator. * This implementation delegates to {@link #doPrevious doPrevious}. * @return the previous object. * @exception NoSuchElementException if the iterator is done. */ @SuppressWarnings("unchecked") public E1 previous() { return (E1)doPrevious(); } /** * Returns the previous object and advances the iterator. * This implementation delegates to {@link BasicEList#get get}. * @return the previous object. * @exception NoSuchElementException if the iterator is done. */ protected E doPrevious() { try { E previous = BasicEList.this.get(--cursor); checkModCount(); lastCursor = cursor; return previous; } catch (IndexOutOfBoundsException exception) { checkModCount(); throw new NoSuchElementException(); } } /** * Returns the index of the object that would be returned by calling {@link #next() next}. * @return the index of the object that would be returned by calling <code>next</code>. */ public int nextIndex() { return cursor; } /** * Returns the index of the object that would be returned by calling {@link #previous previous}. * @return the index of the object that would be returned by calling <code>previous</code>. */ public int previousIndex() { return cursor - 1; } /** * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}. * This implementation delegates to {@link BasicEList#set set}. * @param object the object to set. * @exception IllegalStateException * if <code>next</code> or <code>previous</code> have not yet been called, * or {@link #remove(Object) remove} or {@link #add add} have already been called * after the last call to <code>next</code> or <code>previous</code>. */ @SuppressWarnings("unchecked") public void set(E1 object) { doSet((E)object); } /** * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}. * This implementation delegates to {@link BasicEList#set set}. * @param object the object to set. * @exception IllegalStateException * if <code>next</code> or <code>previous</code> have not yet been called, * or {@link #remove(Object) remove} or {@link #add add} have already been called * after the last call to <code>next</code> or <code>previous</code>. */ protected void doSet(E object) { if (lastCursor == -1) { throw new IllegalStateException(); } checkModCount(); try { BasicEList.this.set(lastCursor, object); } catch (IndexOutOfBoundsException exception) { throw new ConcurrentModificationException(); } } /** * Adds the object at the {@link #next() next} index and advances the iterator past it. * This implementation delegates to {@link #doAdd(Object) doAdd(E)}. * @param object the object to add. */ @SuppressWarnings("unchecked") public void add(E1 object) { doAdd((E)object); } /** * Adds the object at the {@link #next() next} index and advances the iterator past it. * This implementation delegates to {@link BasicEList#add(int, Object) add(int, E)}. * @param object the object to add. */ protected void doAdd(E object) { checkModCount(); try { BasicEList.this.add(cursor++, object); expectedModCount = modCount; lastCursor = -1; } catch (IndexOutOfBoundsException exception) { throw new ConcurrentModificationException(); } } } /** * Returns a read-only list iterator that does not {@link #resolve resolve} objects. * This implementation allocates a {@link NonResolvingEListIterator}. * @return a read-only list iterator that does not resolve objects. */ protected ListIterator<E> basicListIterator() { return new NonResolvingEListIterator<E>();
protected class EListIterator<E1> extends EIterator<E1> implements ListIterator<E1> { /** * Creates an instance. */ public EListIterator() { super(); } /** * Creates an instance advanced to the index. * @param index the starting index. */ public EListIterator(int index) { cursor = index; } /** * Returns whether there are more objects for {@link #previous}. * Returns whether there are more objects. */ public boolean hasPrevious() { return cursor != 0; } /** * Returns the previous object and advances the iterator. * This implementation delegates to {@link #doPrevious doPrevious}. * @return the previous object. * @exception NoSuchElementException if the iterator is done. */ @SuppressWarnings("unchecked") public E1 previous() { return (E1)doPrevious(); } /** * Returns the previous object and advances the iterator. * This implementation delegates to {@link DelegatingEList#get get}. * @return the previous object. * @exception NoSuchElementException if the iterator is done. */ protected E doPrevious() { try { E previous = DelegatingEList.this.get(--cursor); checkModCount(); lastCursor = cursor; return previous; } catch (IndexOutOfBoundsException exception) { checkModCount(); throw new NoSuchElementException(); } } /** * Returns the index of the object that would be returned by calling {@link #next() next}. * @return the index of the object that would be returned by calling <code>next</code>. */ public int nextIndex() { return cursor; } /** * Returns the index of the object that would be returned by calling {@link #previous previous}. * @return the index of the object that would be returned by calling <code>previous</code>. */ public int previousIndex() { return cursor - 1; } /** * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}. * This implementation delegates to {@link #doSet doSet}. * @param object the object to set. * @exception IllegalStateException * if <code>next</code> or <code>previous</code> have not yet been called, * or {@link #remove() remove} or {@link #add add} have already been called * after the last call to <code>next</code> or <code>previous</code>. */ @SuppressWarnings("unchecked") public void set(E1 object) { doSet((E)object); } /** * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}. * This implementation delegates to {@link DelegatingEList#set set}. * @param object the object to set. * @exception IllegalStateException * if <code>next</code> or <code>previous</code> have not yet been called, * or {@link #remove() remove} or {@link #add add} have already been called * after the last call to <code>next</code> or <code>previous</code>. */ protected void doSet(E object) { if (lastCursor == -1) { throw new IllegalStateException(); } checkModCount(); try { DelegatingEList.this.set(lastCursor, object); } catch (IndexOutOfBoundsException exception) { throw new ConcurrentModificationException(); } } /** * Adds the object at the {@link #next() next} index and advances the iterator past it. * This implementation delegates to {@link #doAdd doAdd}. * @param object the object to add. */ @SuppressWarnings("unchecked") public void add(E1 object) { doAdd((E)object); } /** * Adds the object at the {@link #next() next} index and advances the iterator past it. * This implementation delegates to {@link DelegatingEList#add(int, Object) add(int, Object)}. * @param object the object to add. */ protected void doAdd(E object) { checkModCount(); try { DelegatingEList.this.add(cursor++, object); expectedModCount = modCount; lastCursor = -1; } catch (IndexOutOfBoundsException exception) { throw new ConcurrentModificationException(); } } } /** * Returns a read-only list iterator that does not {@link #resolve resolve} objects. * This implementation allocates a {@link NonResolvingEListIterator}. * @return a read-only list iterator that does not resolve objects. */ protected ListIterator<E> basicListIterator() { return new NonResolvingEListIterator<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 EListIterator<E1> extends EIterator<E1> implements ListIterator<E1> 
1
protected class EListIterator<E1> extends EIterator<E1> implements ListIterator<E1>
2
  {
2
  {
3
    /**
3
    /**
4
     * Creates an instance.
4
     * Creates an instance.
5
     */
5
     */
6
    public EListIterator() 
6
    public EListIterator() 
7
    {
7
    {
8
      super();
8
      super();
9
    }
9
    }
10
    /**
10
    /**
11
     * Creates an instance advanced to the index.
11
     * Creates an instance advanced to the index.
12
     * @param index the starting index.
12
     * @param index the starting index.
13
     */
13
     */
14
    public EListIterator(int index) 
14
    public EListIterator(int index) 
15
    {
15
    {
16
      cursor = index;
16
      cursor = index;
17
    }
17
    }
18
    /**
18
    /**
19
     * Returns whether there are more objects for {@link #previous}.
19
     * Returns whether there are more objects for {@link #previous}.
20
     * Returns whether there are more objects.
20
     * Returns whether there are more objects.
21
     */
21
     */
22
    public boolean hasPrevious() 
22
    public boolean hasPrevious() 
23
    {
23
    {
24
      return cursor != 0;
24
      return cursor != 0;
25
    }
25
    }
26
    /**
26
    /**
27
     * Returns the previous object and advances the iterator.
27
     * Returns the previous object and advances the iterator.
28
     * This implementation delegates to {@link #doPrevious doPrevious}.
28
     * This implementation delegates to {@link #doPrevious doPrevious}.
29
     * @return the previous object.
29
     * @return the previous object.
30
     * @exception NoSuchElementException if the iterator is done.
30
     * @exception NoSuchElementException if the iterator is done.
31
     */
31
     */
32
    @SuppressWarnings("unchecked")
32
    @SuppressWarnings("unchecked")
33
    public E1 previous() 
33
    public E1 previous() 
34
    {
34
    {
35
      return (E1)doPrevious();
35
      return (E1)doPrevious();
36
    }
36
    }
37
    /**
37
    /**
38
     * Returns the previous object and advances the iterator.
38
     * Returns the previous object and advances the iterator.
39
     * This implementation delegates to {@link BasicEList#get get}.
39
     * This implementation delegates to {@link DelegatingEList#get get}.
40
     * @return the previous object.
40
     * @return the previous object.
41
     * @exception NoSuchElementException if the iterator is done.
41
     * @exception NoSuchElementException if the iterator is done.
42
     */
42
     */
43
    protected E doPrevious() 
43
    protected E doPrevious() 
44
    {
44
    {
45
      try 
45
      try 
46
      {
46
      {
47
        E previous = BasicEList.this.get(--cursor);
47
        E previous = DelegatingEList.this.get(--cursor);
48
        checkModCount();
48
        checkModCount();
49
        lastCursor = cursor;
49
        lastCursor = cursor;
50
        return previous;
50
        return previous;
51
      } 
51
      } 
52
      catch (IndexOutOfBoundsException exception) 
52
      catch (IndexOutOfBoundsException exception) 
53
      {
53
      {
54
        checkModCount();
54
        checkModCount();
55
        throw new NoSuchElementException();
55
        throw new NoSuchElementException();
56
      }
56
      }
57
    }
57
    }
58
    /**
58
    /**
59
     * Returns the index of the object that would be returned by calling {@link #next() next}.
59
     * Returns the index of the object that would be returned by calling {@link #next() next}.
60
     * @return the index of the object that would be returned by calling <code>next</code>.
60
     * @return the index of the object that would be returned by calling <code>next</code>.
61
     */
61
     */
62
    public int nextIndex() 
62
    public int nextIndex() 
63
    {
63
    {
64
      return cursor;
64
      return cursor;
65
    }
65
    }
66
    /**
66
    /**
67
     * Returns the index of the object that would be returned by calling {@link #previous previous}.
67
     * Returns the index of the object that would be returned by calling {@link #previous previous}.
68
     * @return the index of the object that would be returned by calling <code>previous</code>.
68
     * @return the index of the object that would be returned by calling <code>previous</code>.
69
     */
69
     */
70
    public int previousIndex() 
70
    public int previousIndex() 
71
    {
71
    {
72
      return cursor - 1;
72
      return cursor - 1;
73
    }
73
    }
74
    /**
74
    /**
75
     * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.
75
     * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.
76
     * This implementation delegates to {@link BasicEList#set set}.
76
     * This implementation delegates to {@link #doSet doSet}.
77
     * @param object the object to set.
77
     * @param object the object to set.
78
     * @exception IllegalStateException
78
     * @exception IllegalStateException
79
     * if <code>next</code> or <code>previous</code> have not yet been called,
79
     * if <code>next</code> or <code>previous</code> have not yet been called,
80
     * or {@link #remove(Object) remove} or {@link #add add} have already been called 
80
     * or {@link #remove() remove} or {@link #add add} have already been called 
81
     * after the last call to <code>next</code> or <code>previous</code>.
81
     * after the last call to <code>next</code> or <code>previous</code>.
82
     */
82
     */
83
    @SuppressWarnings("unchecked")
83
    @SuppressWarnings("unchecked")
84
    public void set(E1 object) 
84
    public void set(E1 object) 
85
    {
85
    {
86
      doSet((E)object);  
86
      doSet((E)object);
87
    }
87
    }
88
    /**
88
    /**
89
     * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.
89
     * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.
90
     * This implementation delegates to {@link BasicEList#set set}.
90
     * This implementation delegates to {@link DelegatingEList#set set}.
91
     * @param object the object to set.
91
     * @param object the object to set.
92
     * @exception IllegalStateException
92
     * @exception IllegalStateException
93
     * if <code>next</code> or <code>previous</code> have not yet been called,
93
     * if <code>next</code> or <code>previous</code> have not yet been called,
94
     * or {@link #remove(Object) remove} or {@link #add add} have already been called 
94
     * or {@link #remove() remove} or {@link #add add} have already been called 
95
     * after the last call to <code>next</code> or <code>previous</code>.
95
     * after the last call to <code>next</code> or <code>previous</code>.
96
     */
96
     */
97
    protected void doSet(E object) 
97
    protected void doSet(E object) 
98
    {
98
    {
99
      if (lastCursor == -1)
99
      if (lastCursor == -1)
100
      {
100
      {
101
        throw new IllegalStateException();
101
        throw new IllegalStateException();
102
      }
102
      }
103
      checkModCount();
103
      checkModCount();
104
      try 
104
      try 
105
      {
105
      {
106
        BasicEList.this.set(lastCursor, object);
106
        DelegatingEList.this.set(lastCursor, object);
107
      } 
107
      } 
108
      catch (IndexOutOfBoundsException exception) 
108
      catch (IndexOutOfBoundsException exception) 
109
      {
109
      {
110
        throw new ConcurrentModificationException();
110
        throw new ConcurrentModificationException();
111
      }
111
      }
112
    }
112
    }
113
    /**
113
    /**
114
     * Adds the object at the {@link #next() next} index and advances the iterator past it.
114
     * Adds the object at the {@link #next() next} index and advances the iterator past it.
115
     * This implementation delegates to {@link #doAdd(Object) doAdd(E)}.
115
     * This implementation delegates to {@link #doAdd doAdd}.
116
     * @param object the object to add.
116
     * @param object the object to add.
117
     */
117
     */
118
    @SuppressWarnings("unchecked")
118
    @SuppressWarnings("unchecked")
119
    public void add(E1 object) 
119
    public void add(E1 object) 
120
    {
120
    {
121
      doAdd((E)object);
121
      doAdd((E)object);
122
    }
122
    }
123
    
124
    /**
123
    /**
125
     * Adds the object at the {@link #next() next} index and advances the iterator past it.
124
     * Adds the object at the {@link #next() next} index and advances the iterator past it.
126
     * This implementation delegates to {@link BasicEList#add(int, Object) add(int, E)}.
125
     * This implementation delegates to {@link DelegatingEList#add(int, Object) add(int, Object)}.
127
     * @param object the object to add.
126
     * @param object the object to add.
128
     */
127
     */
129
    protected void doAdd(E object) 
128
    protected void doAdd(E object) 
130
    {
129
    {
131
      checkModCount();
130
      checkModCount();
132
      try 
131
      try 
133
      {
132
      {
134
        BasicEList.this.add(cursor++, object);
133
        DelegatingEList.this.add(cursor++, object);
135
        expectedModCount = modCount;
134
        expectedModCount = modCount;
136
        lastCursor = -1;
135
        lastCursor = -1;
137
      }
136
      }
138
      catch (IndexOutOfBoundsException exception) 
137
      catch (IndexOutOfBoundsException exception) 
139
      {
138
      {
140
        throw new ConcurrentModificationException();
139
        throw new ConcurrentModificationException();
141
      }
140
      }
142
    }
141
    }
143
  }
142
  }
144
  /**
143
  /**
145
   * Returns a read-only list iterator that does not {@link #resolve resolve} objects.
144
   * Returns a read-only list iterator that does not {@link #resolve resolve} objects.
146
   * This implementation allocates a {@link NonResolvingEListIterator}.
145
   * This implementation allocates a {@link NonResolvingEListIterator}.
147
   * @return a read-only list iterator that does not resolve objects.
146
   * @return a read-only list iterator that does not resolve objects.
148
   */
147
   */
149
  protected ListIterator<E> basicListIterator() 
148
  protected ListIterator<E> basicListIterator() 
150
  {
149
  {
151
    return new NonResolvingEListIterator<E>();
150
    return new NonResolvingEListIterator<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