MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / match

Method match

src/main/java/wycc/util/Trie.java:291–316  ·  view source on GitHub ↗
(Trie t, int idIndex, int myIndex, boolean submatch)

Source from the content-addressed store, hash-verified

289 // =========================================================
290
291 private boolean match(Trie t, int idIndex, int myIndex, boolean submatch) {
292 int mySize = depth + 1;
293 if (myIndex == mySize && idIndex == t.size()) {
294 return true;
295 } else if(idIndex == t.size()) {
296 return submatch;
297 } else if (myIndex == mySize) {
298 return false;
299 }
300
301 String myComponent = get(myIndex);
302 if (myComponent.equals("*")) {
303 return match(t, idIndex + 1, myIndex + 1, submatch);
304 } else if (myComponent.equals("**")) {
305 myIndex++;
306 for (int i = idIndex; i <= t.size(); ++i) {
307 if (match(t, i, myIndex, submatch)) {
308 return true;
309 }
310 }
311 return false;
312 } else {
313 return myComponent.equals(t.get(idIndex))
314 && match(t, idIndex + 1, myIndex + 1, submatch);
315 }
316 }
317
318 private static final int binarySearch(final Trie[] children, final int nchildren, final String key) {
319 int low = 0;

Callers 1

matchesMethod · 0.95

Calls 4

getMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected