Example usage for java.util.function ToIntFunction applyAsInt

List of usage examples for java.util.function ToIntFunction applyAsInt

Introduction

In this page you can find the example usage for java.util.function ToIntFunction applyAsInt.

Prototype

int applyAsInt(T value);

Source Link

Document

Applies this function to the given argument.

Usage

From source file:sadl.models.TauPTA.java

private void insertPerLevelAnomaly(IntFunction<List<Transition>> possibleTransitionFunction,
        ToIntFunction<List<Transition>> insertAnomaly) {
    for (int height = 0; height < getTreeHeight(); height++) {
        final TIntList states = getStates(height);
        final List<Transition> allLevelTransitions = new ArrayList<>();
        for (int i = 0; i < states.size(); i++) {
            allLevelTransitions.addAll(getOutTransitions(states.get(i), true));
        }//from w ww .j av  a  2 s .c  om
        int result = 0;
        final List<Transition> possibleTransitions = possibleTransitionFunction.apply(height);
        if (possibleTransitions.size() > 0) {
            // sort for determinism
            Collections.sort(possibleTransitions);
            result = insertAnomaly.applyAsInt(possibleTransitions);
        }
        if (possibleTransitions.size() == 0 || result != 1) {
            logger.warn("It is not possible to insert anomalies on height {}", height);
        }
    }
}