Removes the element at position `index` from the list. Potentially linear complexity.
(&mut self, index: usize, pool: &mut ListPool<T>)
| 566 | |
| 567 | /// Removes the element at position `index` from the list. Potentially linear complexity. |
| 568 | pub fn remove(&mut self, index: usize, pool: &mut ListPool<T>) { |
| 569 | let len; |
| 570 | { |
| 571 | let seq = self.as_mut_slice(pool); |
| 572 | len = seq.len(); |
| 573 | debug_assert!(index < len); |
| 574 | |
| 575 | // Copy elements down. |
| 576 | for i in index..len - 1 { |
| 577 | seq[i] = seq[i + 1]; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | self.remove_last(len, pool); |
| 582 | } |
| 583 | |
| 584 | /// Removes the element at `index` in constant time by switching it with the last element of |
| 585 | /// the list. |