GetNext returns the next unique Tuple from the two TupleIterators.
()
| 110 | |
| 111 | // GetNext returns the next unique Tuple from the two TupleIterators. |
| 112 | func (i *UniqueAttributeIterator) GetNext() (*base.Attribute, bool) { |
| 113 | // Check the first iterator for any next Tuples |
| 114 | for i.iterator1.HasNext() { |
| 115 | attr := i.iterator1.GetNext() // Get the next Tuple |
| 116 | key := attr.GetEntity().GetType() + ":" + attr.GetEntity().GetId() + "$" + attr.GetAttribute() |
| 117 | // If the Tuple hasn't been visited yet, mark it as visited and return it |
| 118 | if _, found := i.visited[key]; !found { |
| 119 | i.visited[key] = true |
| 120 | return attr, true |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // If no more unique Tuples are in the first iterator, check the second one |
| 125 | for i.iterator2.HasNext() { |
| 126 | attr := i.iterator2.GetNext() // Get the next Tuple |
| 127 | key := attr.GetEntity().GetType() + ":" + attr.GetEntity().GetId() + "$" + attr.GetAttribute() |
| 128 | // If the Tuple hasn't been visited yet, mark it as visited and return it |
| 129 | if _, found := i.visited[key]; !found { |
| 130 | i.visited[key] = true |
| 131 | return attr, true |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // If no more unique Tuples are in either of the iterators, return nil |
| 136 | return &base.Attribute{}, false |
| 137 | } |
| 138 | |
| 139 | // SUBJECT |
| 140 |