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

com.github.sirikid.iterators.EmptySpliterator Maven / Gradle / Ivy

/*
 * Copyright (c) 2016, Ivan Sokolov. All rights reserved.
 * This code is licensed under MIT license (see LICENSE for details)
 */

package com.github.sirikid.iterators;

import java.util.Spliterator;
import java.util.function.Consumer;
import javax.annotation.Nullable;

import static java.util.Objects.requireNonNull;

/**
 * Empty spliterator. Use it when need return a spliterator, but you have no elements.
 *
 * @author Ivan Sokolov
 * @version 1.0.0
 * @param  type of elements
 * @see EmptyIterator
 * @since 1.0.0
 */

public class EmptySpliterator implements Spliterator {
	/** {@inheritDoc} */
	@Override
	public boolean tryAdvance(Consumer action) {
		requireNonNull(action);
		return false;
	}

	/** {@inheritDoc} */
	@Nullable
	@Override
	public Spliterator trySplit() {
		return null;
	}

	/** {@inheritDoc} */
	@Override
	public long estimateSize() {
		return 0;
	}

	/** {@inheritDoc} */
	@Override
	public int characteristics() {
		return DISTINCT | SIZED | NONNULL | IMMUTABLE | CONCURRENT | SUBSIZED;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy