| 217 | } |
| 218 | |
| 219 | func (ns nodeSet) List() []*node { |
| 220 | if len(ns) == 0 { |
| 221 | return nil |
| 222 | } |
| 223 | |
| 224 | ret := make([]*node, 0, len(ns)) |
| 225 | |
| 226 | // Determine which list we are working with. We assume here that all of |
| 227 | // the nodes belong to the same list, since that is part of the contract |
| 228 | // for nodeSet. |
| 229 | var list *nodes |
| 230 | for n := range ns { |
| 231 | list = n.list |
| 232 | break |
| 233 | } |
| 234 | |
| 235 | // We recover the order by iterating over the whole list. This is not |
| 236 | // the most efficient way to do it, but our node lists should always be |
| 237 | // small so not worth making things more complex. |
| 238 | for n := list.first; n != nil; n = n.after { |
| 239 | if ns.Has(n) { |
| 240 | ret = append(ret, n) |
| 241 | } |
| 242 | } |
| 243 | return ret |
| 244 | } |
| 245 | |
| 246 | // FindNodeWithContent searches the nodes for a node whose content equals |
| 247 | // the given content. If it finds one then it returns it. Otherwise it returns |