static void Main(string[] args) { PrimitiveCriterion <int> p1 = new PrimitiveCriterion <int>( value => { return(value % 3 == 0); } ); PrimitiveCriterion <int> p2 = new PrimitiveCriterion <int>( value => { return(value % 4 == 0); } ); // NegCriterion not implemented. // Results will be all numbers evenly divisible by BOTH 3 and 4. AndCriterion <int> a1 = new AndCriterion <int>(p1, p2); int[] values = Enumerable.Range(1, 20).ToArray(); foreach (int i in Selector <int> .LazySelected(values, a1)) { Console.Write(i); Console.Write(","); } Console.WriteLine(); foreach (int i in Selector <int> .EagerSelected(values, a1)) { Console.Write(i); Console.Write(","); } }
public void visit(AndCriterion <T> c) { if (!this.satisfies) // We know result is false if previous argument wasn't satisfied. { return; } c.LeftCriterion.accept(this); if (!this.satisfies) // We know result is false if first argument isn't satisfied. { return; } c.RightCriterion.accept(this); }