MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / invariant

Method invariant

validating/CircularQueue.java:67–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65 return true;
66 }
67 private boolean invariant() {
68 // Guarantee that no null values are in the
69 // region of 'data' that holds objects:
70 for(int i = out; i != in; i = (i + 1) % data.length)
71 if(data[i] == null)
72 throw new CircularQueueException(
73 "null in CircularQueue");
74 // Guarantee that only null values are outside the
75 // region of 'data' that holds objects:
76 if(full()) return true;
77 for(int i = in; i != out; i = (i + 1) % data.length)
78 if(data[i] != null)
79 throw new CircularQueueException(
80 "non-null outside of CircularQueue range: "
81 + dump());
82 return true;
83 }
84 public String dump() {
85 return "in = " + in +
86 ", out = " + out +

Callers 3

CircularQueueMethod · 0.95
putMethod · 0.95
getMethod · 0.95

Calls 2

fullMethod · 0.95
dumpMethod · 0.95

Tested by

no test coverage detected