IteratorBase is a set of common methods for Scanner and Index iterators.
| 54 | |
| 55 | // IteratorBase is a set of common methods for Scanner and Index iterators. |
| 56 | type IteratorBase interface { |
| 57 | // String returns a short textual representation of an iterator. |
| 58 | String() string |
| 59 | |
| 60 | // Fills a tag-to-result-value map. |
| 61 | TagResults(map[string]Ref) |
| 62 | |
| 63 | // Returns the current result. |
| 64 | Result() Ref |
| 65 | |
| 66 | // These methods are the heart and soul of the iterator, as they constitute |
| 67 | // the iteration interface. |
| 68 | // |
| 69 | // To get the full results of iteration, do the following: |
| 70 | // |
| 71 | // for graph.Next(it) { |
| 72 | // val := it.Result() |
| 73 | // ... do things with val. |
| 74 | // for it.NextPath() { |
| 75 | // ... find other paths to iterate |
| 76 | // } |
| 77 | // } |
| 78 | // |
| 79 | // All of them should set iterator.result to be the last returned value, to |
| 80 | // make results work. |
| 81 | // |
| 82 | // NextPath() advances iterators that may have more than one valid result, |
| 83 | // from the bottom up. |
| 84 | NextPath(ctx context.Context) bool |
| 85 | |
| 86 | // Err returns any error that was encountered by the Iterator. |
| 87 | Err() error |
| 88 | |
| 89 | // TODO: make a requirement that Err should return ErrClosed after Close is called |
| 90 | |
| 91 | // Close the iterator and do internal cleanup. |
| 92 | Close() error |
| 93 | } |
| 94 | |
| 95 | type Iterator interface { |
| 96 | IteratorBase |
no outgoing calls
no test coverage detected