org.pkl.thirdparty.paguro.collections.UnmodIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pkl-config-java-all Show documentation
Show all versions of pkl-config-java-all Show documentation
Shaded fat Jar for pkl-config-java, a Java config library based on the Pkl config language.
package org.pkl.thirdparty.paguro.collections;
import org.pkl.thirdparty.jetbrains.annotations.Contract;
import org.pkl.thirdparty.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
A one-time use, mutable, not-thread-safe way to get each value of the underling collection in
turn. I experimented with various thread-safe alternatives, but the JVM is optimized around
iterators so this is the lowest common denominator of collection iteration, even though
iterators are inherently mutable.
This is called "Unmod" in the sense that it doesn't modify the underlying collection. Iterators
are inherently mutable. The only safe way to handle them is to pass around IteraBLEs so that
the ultimate client gets its own, unshared iteraTOR. Order is not guaranteed.
*/
public interface UnmodIterator extends Iterator {
// ========================================= Instance =========================================
//default void forEachRemaining(Consumer super E> action)
//boolean hasNext()
//E next()
/** Not allowed - this is supposed to be unmodifiable */
@Override
@Deprecated
default void remove() {
throw new UnsupportedOperationException("Modification attempted");
}
/** Instead of calling this directly, please use {@link #emptyUnmodIterator()} instead */
enum UnIterator implements UnmodIterator
© 2015 - 2024 Weber Informatics LLC | Privacy Policy