| 1498 | |
| 1499 | template<class TBinType> |
| 1500 | THashSet<float> GreedySplit(const TBinType& initialBin, const TMaybe<TVector<float>>& initialBorders, int maxBordersCount) { |
| 1501 | std::priority_queue<TBinType> splits; |
| 1502 | splits.push(initialBin); |
| 1503 | |
| 1504 | while (splits.size() <= (ui32) maxBordersCount && splits.top().CanSplit()) { |
| 1505 | auto top = splits.top(); |
| 1506 | splits.pop(); |
| 1507 | auto left = top.Split(); |
| 1508 | splits.push(left); |
| 1509 | splits.push(top); |
| 1510 | } |
| 1511 | |
| 1512 | THashSet<float> borders; |
| 1513 | borders.reserve(splits.size() - 1); |
| 1514 | while (!splits.empty()) { |
| 1515 | if (!splits.top().IsFirst()) |
| 1516 | borders.insert(splits.top().LeftBorder(initialBorders)); |
| 1517 | splits.pop(); |
| 1518 | } |
| 1519 | return borders; |
| 1520 | } |
| 1521 | |
| 1522 | template<EPenaltyType penaltyType, class TWeightIteratorType> |
| 1523 | THashSet<float> BestWeightedSplitImpl( |