// Operations (type-safe ICloneable) /// <summary> /// /// </summary> /// <returns></returns> public PatternCollection Clone() { PatternCollection tc = new PatternCollection(); tc.AddRange(this); tc.Capacity = this.m_array.Length; tc.m_version = this.m_version; return(tc); }
/// <summary> /// /// </summary> /// <param name="collection"></param> public void AddRange(PatternCollection collection) { // for (int i=0; i < collection.Count; ++i) Add(collection[i]); ++m_version; Capacity += collection.Count; Array.Copy(collection.m_array, 0, this.m_array, m_count, collection.m_count); m_count += collection.Count; }
// Construction public Enumerator(PatternCollection tc) { m_collection = tc; m_index = -1; m_version = tc.m_version; }
/// <summary> /// /// </summary> /// <param name="collection"></param> public PatternCollection(PatternCollection collection) { AddRange(collection); }
// Operations (type-safe ICloneable) /// <summary> /// /// </summary> /// <returns></returns> public PatternCollection Clone() { PatternCollection tc = new PatternCollection(); tc.AddRange(this); tc.Capacity = this.m_array.Length; tc.m_version = this.m_version; return tc; }
public void BuildLookupTable() { IComparer comparer = new PatternComparer(); this.tmpSimplePatterns.Sort(comparer); foreach (Pattern p in tmpSimplePatterns) { if (p.StringPattern.Length <= 2) { char c = p.StringPattern[0]; if (!p.Parent.CaseSensitive) { char c1 = char.ToLower(c); if (LookupTable[c1] == null) LookupTable[c1] = new PatternCollection(); PatternCollection patterns = LookupTable[c1] as PatternCollection; if (!patterns.Contains(p)) patterns.Add(p); char c2 = char.ToUpper(c); if (LookupTable[c2] == null) LookupTable[c2] = new PatternCollection(); patterns = LookupTable[c2] as PatternCollection; if (!patterns.Contains(p)) patterns.Add(p); } else { if (LookupTable[c] == null) LookupTable[c] = new PatternCollection(); PatternCollection patterns = LookupTable[c] as PatternCollection; if (!patterns.Contains(p)) patterns.Add(p); } } else { string c = p.StringPattern.Substring(0, 3).ToLower(); if (LookupTable[c] == null) LookupTable[c] = new PatternCollection(); PatternCollection patterns = LookupTable[c] as PatternCollection; if (!patterns.Contains(p)) patterns.Add(p); } } }
public void BuildLookupTable() { IComparer comparer = new PatternComparer(); this.tmpSimplePatterns.Sort(comparer); foreach (Pattern p in tmpSimplePatterns) { if (p.StringPattern.Length <= 2) { char c = p.StringPattern[0]; if (!p.Parent.CaseSensitive) { char c1 = char.ToLower(c); if (LookupTable[c1] == null) { LookupTable[c1] = new PatternCollection(); } PatternCollection patterns = LookupTable[c1] as PatternCollection; if (!patterns.Contains(p)) { patterns.Add(p); } char c2 = char.ToUpper(c); if (LookupTable[c2] == null) { LookupTable[c2] = new PatternCollection(); } patterns = LookupTable[c2] as PatternCollection; if (!patterns.Contains(p)) { patterns.Add(p); } } else { if (LookupTable[c] == null) { LookupTable[c] = new PatternCollection(); } PatternCollection patterns = LookupTable[c] as PatternCollection; if (!patterns.Contains(p)) { patterns.Add(p); } } } else { string c = p.StringPattern.Substring(0, 3).ToLower(); if (LookupTable[c] == null) { LookupTable[c] = new PatternCollection(); } PatternCollection patterns = LookupTable[c] as PatternCollection; if (!patterns.Contains(p)) { patterns.Add(p); } } } }
/// <summary> /// /// </summary> /// <param name="Pattern"></param> /// <returns></returns> public Pattern Add(Pattern Pattern) { if (this.Parent != null && this.Parent.Parent != null && this.Parent.Parent.Parent != null) { Pattern.Separators = this.Parent.Parent.Parent.Separators; this.Parent.Parent.Parent.ChangeVersion(); } if (!Pattern.IsComplex && !Pattern.ContainsSeparator) { //store pattern in lookuptable if it is a simple pattern string s = ""; if (Pattern.StringPattern.Length >= 2) { s = Pattern.StringPattern.Substring(0, 2); } else { s = Pattern.StringPattern.Substring(0, 1) + " "; } s = s.ToLower(); if (Pattern.StringPattern.Length == 1) { SimplePatterns1Char[Pattern.StringPattern] = Pattern; } else { if (SimplePatterns2Char[s] == null) { SimplePatterns2Char[s] = new PatternCollection(); } PatternCollection ar = (PatternCollection)SimplePatterns2Char[s]; ar.Add(Pattern); } if (this.CaseSensitive) { SimplePatterns[Pattern.LowerStringPattern] = Pattern; } else { SimplePatterns[Pattern.StringPattern] = Pattern; } // if (SimplePatterns[s]==null) // SimplePatterns.Add (s,new ArrayList ()); // // ArrayList bb=(ArrayList) SimplePatterns[s]; // // bb.Add (Pattern); } else { ComplexPatterns.Add(Pattern); } mPatterns.Add(Pattern); if (Pattern.Parent == null) { Pattern.Parent = this; } else { throw(new Exception("Pattern already assigned to another PatternList")); } return(Pattern); }
/// <summary> /// /// </summary> /// <param name="Pattern"></param> /// <returns></returns> public Pattern Add(Pattern Pattern) { if (this.Parent != null && this.Parent.Parent != null && this.Parent.Parent.Parent != null) { Pattern.Separators = this.Parent.Parent.Parent.Separators; this.Parent.Parent.Parent.ChangeVersion(); } if (!Pattern.IsComplex && !Pattern.ContainsSeparator) { //store pattern in lookuptable if it is a simple pattern string s = ""; if (Pattern.StringPattern.Length >= 2) s = Pattern.StringPattern.Substring(0, 2); else s = Pattern.StringPattern.Substring(0, 1) + " "; s = s.ToLower(); if (Pattern.StringPattern.Length == 1) { SimplePatterns1Char[Pattern.StringPattern] = Pattern; } else { if (SimplePatterns2Char[s] == null) SimplePatterns2Char[s] = new PatternCollection(); PatternCollection ar = (PatternCollection) SimplePatterns2Char[s]; ar.Add(Pattern); } if (this.CaseSensitive) SimplePatterns[Pattern.LowerStringPattern] = Pattern; else SimplePatterns[Pattern.StringPattern] = Pattern; // if (SimplePatterns[s]==null) // SimplePatterns.Add (s,new ArrayList ()); // // ArrayList bb=(ArrayList) SimplePatterns[s]; // // bb.Add (Pattern); } else { ComplexPatterns.Add(Pattern); } mPatterns.Add(Pattern); if (Pattern.Parent == null) Pattern.Parent = this; else { throw(new Exception("Pattern already assigned to another PatternList")); } return Pattern; }