Border before element with value "border"
| 696 | |
| 697 | // Border before element with value "border" |
| 698 | static float RegularBorder(float border, const TVector<float>& sortedValues, const TMaybe<TVector<float>>& initialBorders) { |
| 699 | TVector<float>::const_iterator lowerBound = LowerBound(sortedValues.begin(), sortedValues.end(), border); |
| 700 | |
| 701 | if (lowerBound == sortedValues.end()) { // binarizing to always false |
| 702 | if (initialBorders && !initialBorders->empty()) { |
| 703 | if (sortedValues.back() < initialBorders->back()) { |
| 704 | return initialBorders->back(); |
| 705 | } |
| 706 | } |
| 707 | return Max(2.f * sortedValues.back(), sortedValues.back() + 1.f); |
| 708 | } |
| 709 | |
| 710 | if (lowerBound == sortedValues.begin()) {// binarizing to always true |
| 711 | if (initialBorders && !initialBorders->empty()) { |
| 712 | if ((*initialBorders)[0] <= sortedValues.back()) { |
| 713 | return (*initialBorders)[0]; |
| 714 | } |
| 715 | } |
| 716 | return Min(.5f * sortedValues.front(), 2.f * sortedValues.front()); |
| 717 | } |
| 718 | |
| 719 | if (initialBorders) { |
| 720 | const auto possibleBorder = UpperBound(initialBorders->begin(), initialBorders->end(), lowerBound[-1]); |
| 721 | if (possibleBorder != initialBorders->end() && (*possibleBorder) <= lowerBound[0]) { |
| 722 | return (*possibleBorder); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | float res = (lowerBound[0] + lowerBound[-1]) * .5f; |
| 727 | if (res == lowerBound[0]) { // wrong side rounding (should be very scarce) |
| 728 | res = lowerBound[-1]; |
| 729 | } |
| 730 | return res; |
| 731 | } |
| 732 | |
| 733 | |
| 734 | namespace { |
no test coverage detected