Base nexting on interface satisfaction
This is done unsubtlely at the moment and there is plenty of room for optimisation of assertion location to prevent repeated reasserting as is done now.
This commit is contained in:
parent
b498a06a7b
commit
d6f94be514
27 changed files with 57 additions and 82 deletions
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
package iterator
|
||||
|
||||
// Define the general iterator interface, as well as the Base which all
|
||||
// iterators can "inherit" from to get default iterator functionality.
|
||||
// Define the general iterator interface.
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
|
@ -30,14 +29,6 @@ func NextUID() uint64 {
|
|||
return atomic.AddUint64(&nextIteratorID, 1) - 1
|
||||
}
|
||||
|
||||
// The Base iterator is the iterator other iterators inherit from to get some
|
||||
// default functionality.
|
||||
type Base struct {
|
||||
}
|
||||
|
||||
// Accessor
|
||||
func (it *Base) CanNext() bool { return true }
|
||||
|
||||
// Here we define the simplest iterator -- the Null iterator. It contains nothing.
|
||||
// It is the empty set. Often times, queries that contain one of these match nothing,
|
||||
// so it's important to give it a special iterator.
|
||||
|
|
@ -88,8 +79,6 @@ func (it *Null) DebugString(indent int) string {
|
|||
return strings.Repeat(" ", indent) + "(null)"
|
||||
}
|
||||
|
||||
func (it *Null) CanNext() bool { return true }
|
||||
|
||||
func (it *Null) Next() (graph.Value, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue