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