/// <summary> /// Returns the key pattern representation for the merged subkeys from index "from" to index "to". /// </summary> /// <returns></returns> public string GetPatternRangeRepresentation(BigInteger from, BigInteger to) { KeyPattern mergedPattern = new KeyPattern(pattern.GetPattern()); mergedPattern.wildcardList = new ArrayList(); var rangeLength = to - from + 1; for (int i = 0; i < pattern.wildcardList.Count; i++) { //Add all chars of wildcard i from all subpattern in ranche together: HashSet <char> charSet = new HashSet <char>(); for (BigInteger c = from; c <= to; c++) { var wc = (Wildcard)(this[c].wildcardList[i]); for (int x = 0; x < wc.getLength(); x++) { charSet.Add(wc.getChars()[x]); } } //Add merged chars to merged pattern: var mergedChars = new char[charSet.Count]; charSet.CopyTo(mergedChars); mergedPattern.wildcardList.Add(new Wildcard(mergedChars, charSet.Count)); } return(mergedPattern.WildcardKey); }
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); }