MCPcopy
hub / github.com/careercup/ctci / hasCycle

Method hasCycle

java/Chapter 16/Question16_4/LockNode.java:34–40  ·  view source on GitHub ↗
(Hashtable<Integer, Boolean> touchedNodes)

Source from the content-addressed store, hash-verified

32
33 /* Check for a cycle by doing a depth-first-search. */
34 public boolean hasCycle(Hashtable<Integer, Boolean> touchedNodes) {
35 VisitState[] visited = new VisitState[maxLocks];
36 for (int i = 0; i < maxLocks; i++) {
37 visited[i] = VisitState.FRESH;
38 }
39 return hasCycle(visited, touchedNodes);
40 }
41
42 private boolean hasCycle(VisitState[] visited, Hashtable<Integer, Boolean> touchedNodes) {
43 if (touchedNodes.containsKey(lockId)) {

Callers 1

hasCycleMethod · 0.95

Calls 1

putMethod · 0.80

Tested by

no test coverage detected