Rename NextResult -> NextPath

See discussion in #92.
This commit is contained in:
kortschak 2014-08-01 07:27:16 +09:30
parent cb177aa390
commit f8e28e066e
20 changed files with 37 additions and 37 deletions

View file

@ -110,7 +110,7 @@ func (it *Int64) Result() graph.Value {
return it.result
}
func (it *Int64) NextResult() bool {
func (it *Int64) NextPath() bool {
return false
}

View file

@ -236,15 +236,15 @@ func (it *And) Size() (int64, bool) {
return val, b
}
// An And has no NextResult of its own -- that is, there are no other values
// An And has no NextPath of its own -- that is, there are no other values
// which satisfy our previous result that are not the result itself. Our
// subiterators might, however, so just pass the call recursively.
func (it *And) NextResult() bool {
if it.primaryIt.NextResult() {
func (it *And) NextPath() bool {
if it.primaryIt.NextPath() {
return true
}
for _, sub := range it.internalIterators {
if sub.NextResult() {
if sub.NextPath() {
return true
}
}

View file

@ -156,7 +156,7 @@ func (it *Fixed) Result() graph.Value {
return it.result
}
func (it *Fixed) NextResult() bool {
func (it *Fixed) NextPath() bool {
return false
}

View file

@ -27,9 +27,9 @@ package iterator
// value to check, it means "Check all predicates that have this value for your
// direction against the subiterator." This would imply that there's more than
// one possibility for the same Contains()ed value. While we could return the
// number of options, it's simpler to return one, and then call NextResult()
// number of options, it's simpler to return one, and then call NextPath()
// enough times to enumerate the options. (In fact, one could argue that the
// raison d'etre for NextResult() is this iterator).
// raison d'etre for NextPath() is this iterator).
//
// Alternatively, can be seen as the dual of the LinksTo iterator.
@ -175,14 +175,14 @@ func (it *HasA) NextContains() bool {
}
// Get the next result that matches this branch.
func (it *HasA) NextResult() bool {
// Order here is important. If the subiterator has a NextResult, then we
func (it *HasA) NextPath() bool {
// Order here is important. If the subiterator has a NextPath, then we
// need do nothing -- there is a next result, and we shouldn't move forward.
// However, we then need to get the next result from our last Contains().
//
// The upshot is, the end of NextResult() bubbles up from the bottom of the
// The upshot is, the end of NextPath() bubbles up from the bottom of the
// iterator tree up, and we need to respect that.
if it.primaryIt.NextResult() {
if it.primaryIt.NextPath() {
return true
}
return it.NextContains()

View file

@ -95,7 +95,7 @@ func (it *Null) SubIterators() []graph.Iterator {
return nil
}
func (it *Null) NextResult() bool {
func (it *Null) NextPath() bool {
return false
}

View file

@ -183,8 +183,8 @@ func (it *LinksTo) Close() {
}
// We won't ever have a new result, but our subiterators might.
func (it *LinksTo) NextResult() bool {
return it.primaryIt.NextResult()
func (it *LinksTo) NextPath() bool {
return it.primaryIt.NextPath()
}
// Register the LinksTo.

View file

@ -88,9 +88,9 @@ func (it *Optional) Result() graph.Value {
// An optional iterator only has a next result if, (a) last time we checked
// we had any results whatsoever, and (b) there was another subresult in our
// optional subbranch.
func (it *Optional) NextResult() bool {
func (it *Optional) NextPath() bool {
if it.lastCheck {
return it.subIt.NextResult()
return it.subIt.NextPath()
}
return false
}

View file

@ -228,13 +228,13 @@ func (it *Or) Size() (int64, bool) {
return val, b
}
// An Or has no NextResult of its own -- that is, there are no other values
// An Or has no NextPath of its own -- that is, there are no other values
// which satisfy our previous result that are not the result itself. Our
// subiterators might, however, so just pass the call recursively. In the case of
// shortcircuiting, only allow new results from the currently checked graph.iterator
func (it *Or) NextResult() bool {
func (it *Or) NextPath() bool {
if it.currentIterator != -1 {
return it.internalIterators[it.currentIterator].NextResult()
return it.internalIterators[it.currentIterator].NextPath()
}
return false
}

View file

@ -152,9 +152,9 @@ func (it *Comparison) Result() graph.Value {
return it.result
}
func (it *Comparison) NextResult() bool {
func (it *Comparison) NextPath() bool {
for {
hasNext := it.subIt.NextResult()
hasNext := it.subIt.NextPath()
if !hasNext {
return false
}