class Select extends Iterator { Iterator child; Predicate pred; Select (Iterator child, Predicate pred) { this.child = child; this.pred = pred; } Tuple next() { Tuple t; while ((t = child.next()) != null ) { if (pred(t)) { return t; } } return null; } void open() { child.open(); } void close() { child.close(); } }