Breaking out of a recursion in java

后端 未结 11 1470
故里飘歌
故里飘歌 2020-12-01 04:23

The recursion is sort of a \'divide and conquer\' style, it splits up while getting smaller (Tree data structure), and I want it to break completely if a violation is found,

11条回答
  •  甜味超标
    2020-12-01 05:03

    I was able to move out of all recursive calls using a global variable.

    boolean skipRecursivePaths = false;
    private callAgain(){
    
    if(callAgain){
      if(getOutCompletely){
    
        skipRecursivePaths = true;
        }
        if(skipRecursivePaths){
        return;
        }
    }
    

提交回复
热议问题