| 1163 | |
| 1164 | |
| 1165 | static void SortValuesAndInsertDefault( |
| 1166 | TFeatureValues& features, |
| 1167 | TMaybe<size_t>* defaultValueFirstPos) { // out parameter |
| 1168 | |
| 1169 | if (features.DefaultValue) { |
| 1170 | const float defaultValue = features.DefaultValue->Value; |
| 1171 | if (features.ValuesSorted) { |
| 1172 | auto defaultValueFirstPosIter = LowerBound( |
| 1173 | features.Values.begin(), |
| 1174 | features.Values.end(), |
| 1175 | defaultValue); |
| 1176 | |
| 1177 | *defaultValueFirstPos = defaultValueFirstPosIter - features.Values.begin(); |
| 1178 | |
| 1179 | features.Values.insert(defaultValueFirstPosIter, defaultValue); |
| 1180 | } else { |
| 1181 | features.Values.push_back(defaultValue); |
| 1182 | Sort(features.Values); |
| 1183 | |
| 1184 | auto defaultValueFirstPosIter = LowerBound( |
| 1185 | features.Values.begin(), |
| 1186 | features.Values.end(), |
| 1187 | defaultValue); |
| 1188 | |
| 1189 | *defaultValueFirstPos = defaultValueFirstPosIter - features.Values.begin(); |
| 1190 | } |
| 1191 | } else { |
| 1192 | if (!features.ValuesSorted) { |
| 1193 | Sort(features.Values); |
| 1194 | } |
| 1195 | *defaultValueFirstPos = Nothing(); |
| 1196 | } |
| 1197 | features.ValuesSorted = true; |
| 1198 | } |
| 1199 | |
| 1200 | |
| 1201 | TQuantization TMedianBinarizer::BestSplit( |