MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / swap_remove

Method swap_remove

cranelift/entity/src/list.rs:586–595  ·  view source on GitHub ↗

Removes the element at `index` in constant time by switching it with the last element of the list.

(&mut self, index: usize, pool: &mut ListPool<T>)

Source from the content-addressed store, hash-verified

584 /// Removes the element at `index` in constant time by switching it with the last element of
585 /// the list.
586 pub fn swap_remove(&mut self, index: usize, pool: &mut ListPool<T>) {
587 let seq = self.as_mut_slice(pool);
588 let len = seq.len();
589 debug_assert!(index < len);
590 if index != len - 1 {
591 seq.swap(index, len - 1);
592 }
593
594 self.remove_last(len, pool);
595 }
596
597 /// Shortens the list down to `len` elements.
598 ///

Callers 3

runMethod · 0.45

Calls 4

remove_lastMethod · 0.80
as_mut_sliceMethod · 0.45
lenMethod · 0.45
swapMethod · 0.45

Tested by 1

runMethod · 0.36