MCPcopy Create free account
hub / github.com/antchfx/xpath / Select

Method Select

query.go:1141–1180  ·  view source on GitHub ↗
(t iterator)

Source from the content-addressed store, hash-verified

1139}
1140
1141func (u *unionQuery) Select(t iterator) NodeNavigator {
1142 if u.iterator == nil {
1143 var list []NodeNavigator
1144 var m = make(map[uint64]bool)
1145 root := t.Current().Copy()
1146 for {
1147 node := u.Left.Select(t)
1148 if node == nil {
1149 break
1150 }
1151 code := getHashCode(node.Copy())
1152 if _, ok := m[code]; !ok {
1153 m[code] = true
1154 list = append(list, node.Copy())
1155 }
1156 }
1157 t.Current().MoveTo(root)
1158 for {
1159 node := u.Right.Select(t)
1160 if node == nil {
1161 break
1162 }
1163 code := getHashCode(node.Copy())
1164 if _, ok := m[code]; !ok {
1165 m[code] = true
1166 list = append(list, node.Copy())
1167 }
1168 }
1169 var i int
1170 u.iterator = func() NodeNavigator {
1171 if i >= len(list) {
1172 return nil
1173 }
1174 node := list[i]
1175 i++
1176 return node
1177 }
1178 }
1179 return u.iterator()
1180}
1181
1182func (u *unionQuery) Evaluate(t iterator) interface{} {
1183 u.iterator = nil

Callers

nothing calls this directly

Calls 5

getHashCodeFunction · 0.85
CopyMethod · 0.65
CurrentMethod · 0.65
SelectMethod · 0.65
MoveToMethod · 0.65

Tested by

no test coverage detected