use of org.onosproject.net.DefaultOchSignalComparator in project onos by opennetworkinglab.
the class OpticalConnectivityIntentCompiler method findFirstLambda.
/**
* Returns list of consecutive resources in given set of lambdas.
*
* @param lambdas list of lambdas
* @param count number of consecutive lambdas to return
* @return list of consecutive lambdas
*/
private List<OchSignal> findFirstLambda(Set<OchSignal> lambdas, int count) {
// Sort available lambdas
List<OchSignal> lambdaList = new ArrayList<>(lambdas);
lambdaList.sort(new DefaultOchSignalComparator());
// Means there is only exactly one set of lambdas available
if (lambdaList.size() == count) {
return lambdaList;
}
// Look ahead by count and ensure spacing multiplier is as expected (i.e., no gaps)
for (int i = 0; i < lambdaList.size() - count; i++) {
if (lambdaList.get(i).spacingMultiplier() + 2 * count == lambdaList.get(i + count).spacingMultiplier()) {
return lambdaList.subList(i, i + count);
}
}
return Collections.emptyList();
}
Aggregations