MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / check

Method check

src/class129/Code04_FindNear.java:144–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

142 // 验证的过程
143 // 为了测试
144 public static boolean check() {
145 // near1方法会设置to1、dist1、to2、dist2
146 near1();
147 // 把near1方法的结果备份
148 for (int i = 1; i <= n; i++) {
149 a[i] = to1[i];
150 b[i] = dist1[i];
151 c[i] = to2[i];
152 d[i] = dist2[i];
153 }
154 // near2方法会再次设置to1、dist1、to2、dist2
155 near2();
156 // a、b、c、d,是near1生成的结果
157 // to1、dist1、to2、dist2,是near2生成的结果
158 for (int i = 1; i <= n; i++) {
159 if (a[i] != to1[i] || b[i] != dist1[i]) {
160 return false;
161 }
162 }
163 for (int i = 1; i <= n; i++) {
164 if (c[i] != to2[i] || d[i] != dist2[i]) {
165 return false;
166 }
167 }
168 return true;
169 }
170
171 // 对数器
172 // 为了测试

Callers 1

mainMethod · 0.95

Calls 2

near1Method · 0.95
near2Method · 0.95

Tested by

no test coverage detected