(mut self)
| 117 | |
| 118 | #[inline] |
| 119 | pub fn split(mut self) -> [Self; 2] { |
| 120 | self.prepare_sort(); |
| 121 | let half_weight = self.prepare_color_weight_total() / 2.; |
| 122 | // yeah, there's some off-by-one error in there |
| 123 | let break_at = hist_item_sort_half(self.colors, half_weight).max(1); |
| 124 | |
| 125 | let (left, right) = self.colors.split_at_mut(break_at); |
| 126 | let left_sum = left.iter().map(|a| f64::from(a.adjusted_weight)).sum(); |
| 127 | let right_sum = self.adjusted_weight_sum - left_sum; |
| 128 | |
| 129 | [MBox::from_split(left, left_sum), |
| 130 | MBox::from_split(right, right_sum)] |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | #[inline] |
no test coverage detected