Move SubIterator handling out of Base

This commit is contained in:
kortschak 2014-07-30 12:11:14 +09:30
parent 189910c4b8
commit 525230206a
9 changed files with 46 additions and 1 deletions

View file

@ -35,7 +35,7 @@ import (
"github.com/google/cayley/graph"
)
// An optional iterator has the subconstraint iterator we wish to be optional
// An optional iterator has the sub-constraint iterator we wish to be optional
// and whether the last check we received was true or false.
type Optional struct {
Base
@ -95,6 +95,11 @@ func (it *Optional) NextResult() bool {
return false
}
// No subiterators.
func (it *Optional) SubIterators() []graph.Iterator {
return nil
}
// Check() is the real hack of this iterator. It always returns true, regardless
// of whether the subiterator matched. But we keep track of whether the subiterator
// matched for results purposes.