| 199 | } |
| 200 | |
| 201 | static void EncodeTreeImpl(const TDistrTree& t, TVector<ui16>* res) { |
| 202 | if (t.Children.empty()) { |
| 203 | Y_ASSERT(t.FinalNodeId < N_GROUP_FIRST_CODE); |
| 204 | res->push_back(static_cast<ui16>(t.FinalNodeId)); |
| 205 | } else { |
| 206 | if (t.Children.ysize() == 1) |
| 207 | EncodeTreeImpl(t.Children[0], res); |
| 208 | else { |
| 209 | res->push_back(N_GROUP_START); |
| 210 | for (int i = 0; i < t.Children.ysize(); ++i) |
| 211 | EncodeTreeImpl(t.Children[i], res); |
| 212 | res->push_back(N_GROUP_END); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | static void EncodeTree(const TDistrTree& t, TVector<ui16>* res) { |
| 218 | res->resize(0); |
no test coverage detected