Changeset 5a6ee17f
- Timestamp:
- Aug 7, 2018 8:28:16 AM (3 years ago)
- Branches:
- master
- Children:
- 733d3496
- Parents:
- 57fee62
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
router/java/src/net/i2p/router/util/CachedIteratorCollection.java
r57fee62 r5a6ee17f 89 89 @Override 90 90 public boolean add(E element) { 91 final Node<E> newNode = new Node<>( null, element);91 final Node<E> newNode = new Node<>(last, element); 92 92 if (this.size == 0) { 93 93 this.first = newNode; … … 153 153 public void remove() { 154 154 if (nextCalled) { 155 // Are we at the end of the collection? If so itrIndexNode will 156 // be null 155 157 if (itrIndexNode != null) { 156 if (itrIndexNode.prev.prev != null) { 158 // The Node we are trying to remove is itrIndexNode.prev 159 // Is there a Node before itrIndexNode.prev? 160 //if (itrIndexNode.prev != null && itrIndexNode.prev.prev != null) { 161 if (itrIndexNode != first.next) { 162 // Set current itrIndexNode's prev to Node N-2 157 163 itrIndexNode.prev = itrIndexNode.prev.prev; 164 // Then set Node N-2's next to current itrIndexNode, 165 // this drops all references to the Node being removed 158 166 itrIndexNode.prev.next = itrIndexNode; 159 167 } else { 168 // There is no N-2 Node, we are removing the first Node 169 // in the collection 160 170 itrIndexNode.prev = null; 161 171 first = itrIndexNode; 162 172 } 163 173 } else { 174 // itrIndexNode is null, we are at the end of the collection 175 // Are there any items before the Node that is being removed? 164 176 if (last.prev != null) { 165 177 last.prev.next = null; 166 178 last = last.prev; 167 179 } else { 180 // There are no more items, clear() the collection 168 181 nextCalled = false; 169 182 clear(); 170 log.debug("CachedIteratorAbstractCollection: Element Removed");183 //log.debug("CachedIteratorAbstractCollection: Element Removed"); 171 184 return; 172 185 } … … 174 187 size--; 175 188 nextCalled = false; 176 log.debug("CachedIteratorAbstractCollection: Element Removed");189 //log.debug("CachedIteratorAbstractCollection: Element Removed"); 177 190 } else { 178 191 throw new IllegalStateException();
Note: See TracChangeset
for help on using the changeset viewer.