Simplify Nexter interface

This change allows a Nexter to be used in the same manner as a scanner
using a for graph.Next(it) {} construction.

It is important that graph.Next(it) and any associated it.Result() calls
operate on the same iterator.
This commit is contained in:
kortschak 2014-08-01 09:15:02 +09:30
parent f8e28e066e
commit b1a70d99aa
31 changed files with 168 additions and 233 deletions

View file

@ -36,15 +36,13 @@ func (it *AllIterator) SubIterators() []graph.Iterator {
return nil
}
func (it *AllIterator) Next() (graph.Value, bool) {
next, out := it.Int64.Next()
if !out {
return next, out
func (it *AllIterator) Next() bool {
if !it.Int64.Next() {
return false
}
i64 := next.(int64)
_, ok := it.ts.revIdMap[i64]
_, ok := it.ts.revIdMap[it.Int64.Result().(int64)]
if !ok {
return it.Next()
}
return next, out
return true
}