| 605 | } |
| 606 | |
| 607 | CodePoint sample(UInt64 random, double end_multiplier) const |
| 608 | { |
| 609 | UInt64 range = total + static_cast<UInt64>(static_cast<double>(count_end) * end_multiplier); |
| 610 | if (range == 0) |
| 611 | return END; |
| 612 | |
| 613 | random %= range; |
| 614 | |
| 615 | UInt64 sum = 0; |
| 616 | for (const auto & elem : buckets) |
| 617 | { |
| 618 | sum += elem.second; |
| 619 | if (sum > random) |
| 620 | return elem.first; |
| 621 | } |
| 622 | |
| 623 | return END; |
| 624 | } |
| 625 | |
| 626 | void serialize(WriteBuffer & out) const |
| 627 | { |