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

marcel.lang.primitives.iterable.CharIterable Maven / Gradle / Ivy

/*
	* Copyright (C) 2002-2022 Sebastiano Vigna
	*
	* Licensed under the Apache License, Version 2.0 (the "License");
	* you may not use this file except in compliance with the License.
	* You may obtain a copy of the License at
	*
	*     http://www.apache.org/licenses/LICENSE-2.0
	*
	* Unless required by applicable law or agreed to in writing, software
	* distributed under the License is distributed on an "AS IS" BASIS,
	* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	* See the License for the specific language governing permissions and
	* limitations under the License.
	*/
package marcel.lang.primitives.iterable;

import marcel.lang.primitives.iterators.CharIterator;
import marcel.lang.util.function.CharConsumer;

import java.util.function.Consumer;

/** A type-specific {@link Iterable} that strengthens that specification of {@link #iterator()} and {@link #forEach(Consumer)}.
	*
	* @see Iterable
	*/
public interface CharIterable extends Iterable {
	/** Returns a type-specific iterator.
	 *
	 * Note that this specification strengthens the one given in {@link Iterable#iterator()}.
	 *
	 * @return a type-specific iterator.
	 * @see Iterable#iterator()
	 */
	@Override
	CharIterator iterator();

	/**
	 * Performs the given action for each element of this type-specific {@link Iterable}
	 * until all elements have been processed or the action throws an
	 * exception.
	 *
	 * @param action the action to be performed for each element.
	 * @see Iterable#forEach(Consumer)
	 * @since 8.0.0
	 * Implementing classes should generally override this method, and take the default
	 *   implementation of the other overloads which will delegate to this method (after proper
	 *   conversions).
	 */
	default void forEach(final CharConsumer action) {
		iterator().forEachRemaining(action);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy