Example usage for org.apache.commons.collections IteratorUtils toList

List of usage examples for org.apache.commons.collections IteratorUtils toList

Introduction

In this page you can find the example usage for org.apache.commons.collections IteratorUtils toList.

Prototype

public static List toList(Iterator iterator, int estimatedSize) 

Source Link

Document

Gets a list based on an iterator.

Usage

From source file:org.optaplanner.core.impl.heuristic.selector.variable.PlanningValueSelector.java

private void initSelectedPlanningValueList(AbstractSolverPhaseScope phaseScope) {
    if (valueRangeDescriptor.isEntityIndependent()) {
        ValueRange<?> valueRange = ((EntityIndependentPlanningValueRangeDescriptor) valueRangeDescriptor)
                .extractValueRange(phaseScope.getWorkingSolution());
        cachedPlanningValues = IteratorUtils.toList(valueRange.createOriginalIterator(),
                (int) valueRange.getSize());
    } else {//from  www . jav a  2  s. co  m
        cachedPlanningValues = null;
    }
}

From source file:org.optaplanner.core.impl.heuristic.selector.variable.PlanningValueSelector.java

public Iterator<?> iterator(Object planningEntity) {
    if (cachedPlanningValues != null) {
        return cachedPlanningValues.iterator();
    } else {//from  w  w w  . j av a  2s .c  o m
        ValueRange<?> valueRange = valueRangeDescriptor.extractValueRange(scoreDirector.getWorkingSolution(),
                planningEntity);
        List<?> values = IteratorUtils.toList(valueRange.createOriginalIterator(), (int) valueRange.getSize());
        return values.iterator();
    }
}