class AbstractNPointCrossoverReproductionOperator extends AbstractCrossoverReproductionOperator {

    protected boolean[] makeCutPointFlags(int numCrossings, int arrayLength){
        int[] indexes = new int[numCrossings];
        // trivial case when numCrossings is by one smaller than dimension count
        if ((numCrossings + 1) == arrayLength){
            for (int i = 0; i < numCrossings; i++){
                indexes[i] = i + 1;
            }
        } else {
            // generating of cross points into set which is ordered and then transform it into int[].
            Set<Integer> indexSet = new TreeSet<Integer>();
            while (indexSet.size() < numCrossings){
                indexSet.add(this.randomGenerator.nextInt(1, arrayLength));
            }

            // probably the best solution without creating temporary Integer[] array from indexSet
            int idx = 0;
            for (Integer integer : indexSet){
                indexes[idx++] = integer;
            }
        }
        // we have generated cross points and now can generate boolean flag array
        boolean[] flagArray = new boolean[arrayLength];
        boolean flag = true;
        int index = 0;
        for (int i = 0; i < arrayLength; i++){
            // if at inverting position then invert and shift index
            if (index < numCrossings && indexes[index] == i){
                flag = !flag;
                index++;
            }
            flagArray[i] = flag;
        }
        return flagArray;
    }

}