| 114 | } |
| 115 | |
| 116 | private class HashIterator<E> implements Iterator<E> { |
| 117 | int position, expectedModCount; |
| 118 | |
| 119 | final MapEntry.Type<E, K, V> type; |
| 120 | |
| 121 | Entry<K, V> lastEntry; |
| 122 | |
| 123 | int lastPosition; |
| 124 | |
| 125 | boolean canRemove = false; |
| 126 | |
| 127 | HashIterator(MapEntry.Type<E, K, V> value) { |
| 128 | type = value; |
| 129 | position = lastSlot; |
| 130 | expectedModCount = modCount; |
| 131 | } |
| 132 | |
| 133 | public boolean hasNext() { |
| 134 | if (lastEntry != null && lastEntry.next != null) { |
| 135 | return true; |
| 136 | } |
| 137 | while (position >= firstSlot) { |
| 138 | if (elementData[position] == null) { |
| 139 | position--; |
| 140 | } else { |
| 141 | return true; |
| 142 | } |
| 143 | } |
| 144 | return false; |
| 145 | } |
| 146 | |
| 147 | public E next() { |
| 148 | if (expectedModCount == modCount) { |
| 149 | if (lastEntry != null) { |
| 150 | lastEntry = lastEntry.next; |
| 151 | } |
| 152 | if (lastEntry == null) { |
| 153 | while (position >= firstSlot |
| 154 | && (lastEntry = elementData[position]) == null) { |
| 155 | position--; |
| 156 | } |
| 157 | if (lastEntry != null) { |
| 158 | lastPosition = position; |
| 159 | // decrement the position so we don't find the same slot |
| 160 | // next time |
| 161 | position--; |
| 162 | } |
| 163 | } |
| 164 | if (lastEntry != null) { |
| 165 | canRemove = true; |
| 166 | return type.get(lastEntry); |
| 167 | } |
| 168 | throw new NoSuchElementException(); |
| 169 | } |
| 170 | throw new ConcurrentModificationException(); |
| 171 | } |
| 172 | |
| 173 | public void remove() { |
nothing calls this directly
no outgoing calls
no test coverage detected