Example usage for com.google.common.base Preconditions checkPositionIndexes

List of usage examples for com.google.common.base Preconditions checkPositionIndexes

Introduction

In this page you can find the example usage for com.google.common.base Preconditions checkPositionIndexes.

Prototype

public static void checkPositionIndexes(int start, int end, int size) 

Source Link

Document

Ensures that start and end specify a valid positions in an array, list or string of size size , and are in order.

Usage

From source file:net.automatalib.commons.util.array.RichArray.java

public RichArray<T> parallelTransform(int startInclusive, int endExclusive,
        Function<? super T, ? extends T> transformer) {
    Preconditions.checkPositionIndexes(startInclusive, endExclusive, length);
    Objects.requireNonNull(transformer);
    IntStream.range(start + startInclusive, start + endExclusive).parallel()
            .forEach(i -> contents[i] = transformer.apply(contents[i]));
    return this;
}

From source file:net.automatalib.commons.util.array.RichArray.java

public RichArray<T> transformWithIndex(int startInclusive, int endExclusive,
        WithIndexTransformer<? super T, ? extends T> transformer) {
    Preconditions.checkPositionIndexes(startInclusive, endExclusive, length);
    Objects.requireNonNull(transformer);
    IntStream.range(start + startInclusive, start + endExclusive)
            .forEach(i -> contents[i] = transformer.apply(i - start, contents[i]));
    return this;
}

From source file:net.automatalib.commons.util.array.RichArray.java

public RichArray<T> parallelTransformWithIndex(int startInclusive, int endExclusive,
        WithIndexTransformer<? super T, ? extends T> transformer) {
    Preconditions.checkPositionIndexes(startInclusive, endExclusive, length);
    Objects.requireNonNull(transformer);
    IntStream.range(start + startInclusive, start + endExclusive).parallel()
            .forEach(i -> contents[i] = transformer.apply(i - start, contents[i]));
    return this;
}