File tree Expand file tree Collapse file tree 3 files changed +6
-12
lines changed
src/main/java/edu/princeton/cs/algs4 Expand file tree Collapse file tree 3 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -185,11 +185,9 @@ private void validateVertices(Iterable<Integer> vertices) {
185
185
int V = marked .length ;
186
186
for (Integer v : vertices ) {
187
187
if (v == null ) {
188
- throw new IllegalArgumentException ("vertex " + v + " is null" );
189
- }
190
- if (v < 0 || v >= V ) {
191
- throw new IllegalArgumentException ("vertex " + v + " is not between 0 and " + (V -1 ));
188
+ throw new IllegalArgumentException ("vertex is null" );
192
189
}
190
+ validateVertex (v );
193
191
}
194
192
}
195
193
Original file line number Diff line number Diff line change @@ -248,11 +248,9 @@ private void validateVertices(Iterable<Integer> vertices) {
248
248
int V = marked .length ;
249
249
for (Integer v : vertices ) {
250
250
if (v == null ) {
251
- throw new IllegalArgumentException ("vertex " + v + " is null" );
252
- }
253
- if (v < 0 || v >= V ) {
254
- throw new IllegalArgumentException ("vertex " + v + " is not between 0 and " + (V -1 ));
251
+ throw new IllegalArgumentException ("vertex is null" );
255
252
}
253
+ validateVertex (v );
256
254
}
257
255
}
258
256
Original file line number Diff line number Diff line change @@ -121,11 +121,9 @@ private void validateVertices(Iterable<Integer> vertices) {
121
121
int V = marked .length ;
122
122
for (Integer v : vertices ) {
123
123
if (v == null ) {
124
- throw new IllegalArgumentException ("vertex " + v + " is null" );
125
- }
126
- if (v < 0 || v >= V ) {
127
- throw new IllegalArgumentException ("vertex " + v + " is not between 0 and " + (V -1 ));
124
+ throw new IllegalArgumentException ("vertex is null" );
128
125
}
126
+ validateVertex (v );
129
127
}
130
128
}
131
129
You can’t perform that action at this time.
0 commit comments