All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jhotdraw8.collection.primitive.SpliteratorOfByte Maven / Gradle / Ivy

The newest version!
/*
 * @(#)SpliteratorOfByte.java
 * Copyright © 2023 The authors and contributors of JHotDraw. MIT License.
 */

package org.jhotdraw8.collection.primitive;

import org.jspecify.annotations.Nullable;

import java.util.Spliterator;
import java.util.function.Consumer;

public interface SpliteratorOfByte extends Spliterator.OfPrimitive {

    @Override
    @Nullable SpliteratorOfByte trySplit();

    @Override
    boolean tryAdvance(ByteConsumer action);

    @Override
    default void forEachRemaining(ByteConsumer action) {
        do {
        } while (tryAdvance(action));
    }

    @Override
    default boolean tryAdvance(Consumer action) {
        if (action instanceof ByteConsumer) {
            return tryAdvance((ByteConsumer) action);
        } else {
            return tryAdvance((ByteConsumer) action::accept);
        }
    }

    @Override
    default void forEachRemaining(Consumer action) {
        if (action instanceof ByteConsumer) {
            forEachRemaining((ByteConsumer) action);
        } else {
            forEachRemaining((ByteConsumer) action::accept);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy