88 } 89 90 /** 91 * Determines if one loop is a transitive parent of another loop. 92 * 93 * @param childLoop The loop for which parentLoop might be a transitive parent loop. 94 * @param parentLoop The loop which might be a transitive parent loop of child loop. 95 * @return {@code true} if parentLoop is a (transitive) parent loop of childLoop, {@code false} 96 * otherwise 97 */ 98 public static <T extends AbstractBlockBase<T>> boolean transitiveParentLoop(Loop<T> childLoop, Loop<T> parentLoop) { 99 Loop<T> curr = childLoop; 100 while (curr != null) { 101 if (curr == parentLoop) { 102 return true; 103 } 104 curr = curr.getParent(); 105 } 106 return false; 107 } 108 } | 88 } 89 90 /** 91 * Determines if one loop is a transitive parent of another loop. 92 * 93 * @param childLoop The loop for which parentLoop might be a transitive parent loop. 94 * @param parentLoop The loop which might be a transitive parent loop of child loop. 95 * @return {@code true} if parentLoop is a (transitive) parent loop of childLoop, {@code false} 96 * otherwise 97 */ 98 public static <T extends AbstractBlockBase<T>> boolean transitiveParentLoop(Loop<T> childLoop, Loop<T> parentLoop) { 99 Loop<T> curr = childLoop; 100 while (curr != null) { 101 if (curr == parentLoop) { 102 return true; 103 } 104 curr = curr.getParent(); 105 } 106 return false; 107 } 108 109 @Override 110 public int hashCode() { 111 return index + depth * 31; 112 } 113 } |