From 189910c4b8a84e994e41ab73b1c42170ee3391d0 Mon Sep 17 00:00:00 2001 From: kortschak Date: Wed, 30 Jul 2014 12:08:44 +0930 Subject: [PATCH] Remove Base dependency from Null --- graph/iterator/iterator.go | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/graph/iterator/iterator.go b/graph/iterator/iterator.go index 130dd6c..6ec1533 100644 --- a/graph/iterator/iterator.go +++ b/graph/iterator/iterator.go @@ -85,26 +85,18 @@ func (it *Base) Size() (int64, bool) { return 0, true } -// No subiterators. Only those with subiterators need to do anything here. -func (it *Base) SubIterators() []graph.Iterator { - return nil -} - // Accessor func (it *Base) CanNext() bool { return it.canNext } // Nothing to clean up. // func (it *Base) Close() {} -func (it *Null) Close() {} - func (it *Base) Reset() {} -// Here we define the simplest base iterator -- the Null iterator. It contains nothing. +// 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. type Null struct { - Base uid uint64 tags graph.Tagger } @@ -133,6 +125,10 @@ func (it *Null) TagResults(dst map[string]graph.Value) { } } +func (it *Null) Check(graph.Value) bool { + return false +} + func (it *Null) Clone() graph.Iterator { return NewNull() } // Name the null iterator. @@ -147,6 +143,37 @@ 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 +} + +func (it *Null) Result() graph.Value { + return nil +} + +func (it *Null) ResultTree() *graph.ResultTree { + tree := graph.NewResultTree(it.Result()) + return tree +} + +func (it *Null) SubIterators() []graph.Iterator { + return nil +} + +func (it *Null) NextResult() bool { + return false +} + +func (it *Null) Size() (int64, bool) { + return 0, true +} + +func (it *Null) Reset() {} + +func (it *Null) Close() {} + // A null iterator costs nothing. Use it! func (it *Null) Stats() graph.IteratorStats { return graph.IteratorStats{}