MCPcopy Create free account
hub / github.com/antlr/codebuff / unmodifiableIterator

Method unmodifiableIterator

output/java_guava/1.4.19/Iterators.java:163–181  ·  view source on GitHub ↗

Returns an unmodifiable view of iterator.

(final Iterator<? extends T> iterator)

Source from the content-addressed store, hash-verified

161
162
163 public static <T> UnmodifiableIterator<T> unmodifiableIterator(final Iterator<? extends T> iterator) {
164 checkNotNull(iterator);
165 if (iterator instanceof UnmodifiableIterator) {
166 @SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
167 UnmodifiableIterator<T> result = (UnmodifiableIterator<T>) iterator;
168 return result;
169 }
170 return new UnmodifiableIterator<T>() {
171 @Override
172 public boolean hasNext() {
173 return iterator.hasNext();
174 }
175
176 @Override
177 public T next() {
178 return iterator.next();
179 }
180 };
181 }
182
183 /**
184 * Simply returns its argument.

Callers 6

iteratorMethod · 0.95
iteratorMethod · 0.95
iteratorMethod · 0.95
keyIteratorMethod · 0.95
iteratorMethod · 0.95
descendingIteratorMethod · 0.95

Calls 1

checkNotNullMethod · 0.45

Tested by

no test coverage detected