| 134 // I : Iterator<Item=F>, |
134 // I : Iterator<Item=F>, |
| 135 // G : Fn(F, I::Item) -> F |
135 // G : Fn(F, I::Item) -> F |
| 136 // > (&mut self, iter : I, g : G) { |
136 // > (&mut self, iter : I, g : G) { |
| 137 // self.spikes.iter_mut().zip(iter).for_each(|(δ, v)| δ.set_mass(g(δ.get_mass(), v))); |
137 // self.spikes.iter_mut().zip(iter).for_each(|(δ, v)| δ.set_mass(g(δ.get_mass(), v))); |
| 138 // } |
138 // } |
| |
139 |
| |
140 /// Truncate to `len`. |
| |
141 #[inline] |
| |
142 pub fn truncate(&mut self, len: usize) { |
| |
143 self.spikes.truncate(len); |
| |
144 } |
| 139 |
145 |
| 140 /// Prune all spikes with zero mass. |
146 /// Prune all spikes with zero mass. |
| 141 #[inline] |
147 #[inline] |
| 142 pub fn prune(&mut self) { |
148 pub fn prune(&mut self) { |
| 143 self.prune_by(|δ| δ.α != F::ZERO); |
149 self.prune_by(|δ| δ.α != F::ZERO); |