| 164 | } |
| 165 | |
| 166 | std::vector<NodeIndex> |
| 167 | NodeIndex::dirpath(LeafCount n) |
| 168 | { |
| 169 | if (val >= NodeCount(n).val) { |
| 170 | throw InvalidParameterError("Request for dirpath outside of tree"); |
| 171 | } |
| 172 | |
| 173 | auto d = std::vector<NodeIndex>{}; |
| 174 | |
| 175 | auto r = root(n); |
| 176 | if (*this == r) { |
| 177 | return d; |
| 178 | } |
| 179 | |
| 180 | auto p = parent(); |
| 181 | while (p.val != r.val) { |
| 182 | d.push_back(p); |
| 183 | p = p.parent(); |
| 184 | } |
| 185 | |
| 186 | // Include the root except in a one-member tree |
| 187 | if (val != r.val) { |
| 188 | d.push_back(p); |
| 189 | } |
| 190 | |
| 191 | return d; |
| 192 | } |
| 193 | |
| 194 | std::vector<NodeIndex> |
| 195 | NodeIndex::copath(LeafCount n) |
no test coverage detected