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

Method remove

cranelift/entity/src/list.rs:568–582  ·  view source on GitHub ↗

Removes the element at position `index` from the list. Potentially linear complexity.

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

Source from the content-addressed store, hash-verified

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.

Callers 1

insert_removeFunction · 0.45

Calls 3

remove_lastMethod · 0.80
as_mut_sliceMethod · 0.45
lenMethod · 0.45

Tested by 1

insert_removeFunction · 0.36