private bool Until<T1>(PatternMatcher matcher, Func<T1, bool> callback, bool breakCondition) where T1 : class, IInDictElement { bool result = !breakCondition; var en = _Elements.GetEnumerator(); while (en.MoveNext()) { if (en.Current.Value is T1) { bool matched = (matcher == null) ||matcher.IsMatched(en.Current.Key); if (matched) { if (callback(en.Current.Value as T1) == breakCondition) { result = breakCondition; break; } } } } return result; }
public List<T> Matched(PatternMatcher matcher) { return Matched<T>(matcher); }
public bool UntilFalse(PatternMatcher matcher, Func<T, bool> callback) { return Until<T>(matcher, callback, false); }
public bool UntilTrue(PatternMatcher matcher, Func<T, bool> callback) { return Until<T>(matcher, callback, true); }
public void ForEach(PatternMatcher matcher, Action<T> callback) { ForEach<T>(matcher, callback); }
public bool UntilFalse<T1>(PatternMatcher matcher, Func<T1, bool> callback) where T1 : class, IInDictElement { return Until(matcher, callback, false); }
public void ForEach<T1>(PatternMatcher matcher, Action<T1> callback) where T1 : class, IInDictElement { UntilTrue<T1>(matcher, (T1 element) => { callback(element); return false; }); }