CombinatorialIntCustomizer nextAttempt()

in src/main/java/org/jetbrains/jetCheck/IntCustomizer.java [104:119]


  CombinatorialIntCustomizer nextAttempt() {
    Map<NodeId, Integer> nextCombination = new HashMap<>(currentCombination);
    for (Map.Entry<NodeId, Set<Integer>> entry : valuesToTry.entrySet()) {
      List<Integer> possibleValues = new ArrayList<>(entry.getValue());
      Integer usedValue = currentCombination.get(entry.getKey());
      int index = possibleValues.indexOf(usedValue);
      if (index < possibleValues.size() - 1) {
        // found a position which can be incremented by 1
        nextCombination.put(entry.getKey(), possibleValues.get(index + 1));
        return new CombinatorialIntCustomizer(valuesToTry, nextCombination);
      }
      // digit overflow in this position, so zero it and try incrementing the next one
      nextCombination.put(entry.getKey(), possibleValues.get(0));
    }
    return null;
  }