public bool Contains(KeyPattern pattern) { if (pattern.wildcardList.Count != this.pattern.wildcardList.Count) { return(false); } if (pattern.GetPattern() != this.pattern.GetPattern()) { return(false); } bool equal = true; for (int k = 0; k < pattern.wildcardList.Count; k++) { Wildcard wc = ((Wildcard)pattern.wildcardList[k]); Wildcard thiswc = ((Wildcard)this.pattern.wildcardList[k]); if (wc.size() != (thiswc.size() / splittingQuotient[k])) { return(false); } bool bolContains2 = true; int begin = equal ? splittingCounter[k] : 0; for (int j = begin; j < splittingQuotient[k]; j++) { bool bolContains = true; for (int i = 0; i < wc.size(); i++) { if (wc.getChar(i - wc.count()) != thiswc.getChar(i + j * wc.size())) { bolContains = false; break; } } if (bolContains) { equal = (j == splittingCounter[k]); bolContains2 = true; break; } } if (!bolContains2) { return(false); } } return(!equal); }
public KeyPattern[] split() { KeyPattern[] patterns = new KeyPattern[2]; for (int i = 0; i < 2; i++) { patterns[i] = new KeyPattern(pattern); patterns[i].wildcardList = new ArrayList(); } bool s = false; for (int i = 0; i < wildcardList.Count; i++) { Wildcard wc = ((Wildcard)wildcardList[i]); if (!s && (wc.size() - wc.count()) > 1) { Wildcard[] wcs = wc.split(); patterns[0].wildcardList.Add(wcs[0]); patterns[1].wildcardList.Add(wcs[1]); s = true; } else { patterns[0].wildcardList.Add(new Wildcard(wc)); Wildcard copy = new Wildcard(wc); if (s) { copy.resetCounter(); } patterns[1].wildcardList.Add(copy); } } if (!s) { return(null); } return(patterns); }