com.gs.collections.impl.utility.internal.primitive.FloatIterableIterate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gs-collections Show documentation
Show all versions of gs-collections Show documentation
GS Collections is a collections framework for Java. It has JDK-compatible List, Set and Map
implementations with a rich API and set of utility classes that work with any JDK compatible Collections,
Arrays, Maps or Strings. The iteration protocol was inspired by the Smalltalk collection framework.
/*
* Copyright 2014 Goldman Sachs.
*
* 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 com.gs.collections.impl.utility.internal.primitive;
import java.io.IOException;
import java.util.Collection;
import com.gs.collections.api.FloatIterable;
import com.gs.collections.api.block.function.primitive.FloatToObjectFunction;
import com.gs.collections.api.block.function.primitive.ObjectFloatToObjectFunction;
import com.gs.collections.api.block.predicate.primitive.FloatPredicate;
import com.gs.collections.api.block.procedure.primitive.FloatProcedure;
import com.gs.collections.api.collection.primitive.MutableFloatCollection;
import com.gs.collections.api.iterator.FloatIterator;
/**
* This file was automatically generated from template file primitiveIterableIterate.stg.
*
* @since 5.0
*/
public final class FloatIterableIterate
{
private FloatIterableIterate()
{
throw new AssertionError("Suppress default constructor for noninstantiability");
}
public static boolean isEmpty(FloatIterable iterable)
{
return !iterable.floatIterator().hasNext();
}
public static boolean notEmpty(FloatIterable iterable)
{
return !FloatIterableIterate.isEmpty(iterable);
}
public static void forEach(FloatIterable iterable, FloatProcedure procedure)
{
FloatIteratorIterate.forEach(iterable.floatIterator(), procedure);
}
public static R select(FloatIterable iterable, FloatPredicate predicate, R targetCollection)
{
return FloatIteratorIterate.select(iterable.floatIterator(), predicate, targetCollection);
}
public static R reject(FloatIterable iterable, FloatPredicate predicate, R targetCollection)
{
return FloatIteratorIterate.reject(iterable.floatIterator(), predicate, targetCollection);
}
public static > R collect(
FloatIterable iterable,
FloatToObjectFunction extends V> function,
R targetCollection)
{
return FloatIteratorIterate.collect(iterable.floatIterator(), function, targetCollection);
}
public static float detectIfNone(FloatIterable iterable, FloatPredicate predicate, float ifNone)
{
return FloatIteratorIterate.detectIfNone(iterable.floatIterator(), predicate, ifNone);
}
public static int count(FloatIterable iterable, FloatPredicate predicate)
{
return FloatIteratorIterate.count(iterable.floatIterator(), predicate);
}
public static boolean anySatisfy(FloatIterable iterable, FloatPredicate predicate)
{
return FloatIteratorIterate.anySatisfy(iterable.floatIterator(), predicate);
}
public static boolean allSatisfy(FloatIterable iterable, FloatPredicate predicate)
{
return FloatIteratorIterate.allSatisfy(iterable.floatIterator(), predicate);
}
public static boolean noneSatisfy(FloatIterable iterable, FloatPredicate predicate)
{
return FloatIteratorIterate.noneSatisfy(iterable.floatIterator(), predicate);
}
public static double sum(FloatIterable iterable)
{
return FloatIteratorIterate.sum(iterable.floatIterator());
}
public static float max(FloatIterable iterable)
{
return FloatIteratorIterate.max(iterable.floatIterator());
}
public static float maxIfEmpty(FloatIterable iterable, float ifEmpty)
{
if (FloatIterableIterate.isEmpty(iterable))
{
return ifEmpty;
}
return FloatIteratorIterate.max(iterable.floatIterator());
}
public static float min(FloatIterable iterable)
{
return FloatIteratorIterate.min(iterable.floatIterator());
}
public static float minIfEmpty(FloatIterable iterable, float ifEmpty)
{
if (FloatIterableIterate.isEmpty(iterable))
{
return ifEmpty;
}
return FloatIteratorIterate.min(iterable.floatIterator());
}
public static void appendString(
FloatIterable iterable,
Appendable appendable,
String start,
String separator,
String end)
{
try
{
appendable.append(start);
FloatIterator iterator = iterable.floatIterator();
if (iterator.hasNext())
{
appendable.append(stringValueOfItem(iterable, iterator.next()));
while (iterator.hasNext())
{
appendable.append(separator);
appendable.append(stringValueOfItem(iterable, iterator.next()));
}
}
appendable.append(end);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
public static T injectInto(FloatIterable iterable, T injectedValue, ObjectFloatToObjectFunction super T, ? extends T> function)
{
return FloatIteratorIterate.injectInto(iterable.floatIterator(), injectedValue, function);
}
private static String stringValueOfItem(FloatIterable iterable, T item)
{
return item == iterable
? "(this " + iterable.getClass().getSimpleName() + ')'
: String.valueOf(item);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy