Skip to content

num::swap_remove_plan

Defined in header <container/swap_remove.hpp>

array<index_move> swap_remove_plan(idx n, view<const idx> removed);

Plan the relocations that compact n elements after removing some.

Each hole is filled from the tail, which is O(1) per removal but renames the moved elements. The returned renames let parallel arrays and held indices follow. Holes and survivors are taken in ascending order, so the plan ignores the order of removed.

Parameters

  • n: Current number of elements.
  • removed: Indices to remove. Must be distinct and less than n.

Return value

One move per hole that a survivor fills; empty when the removed indices are exactly the tail.

Exceptions

  • std::out_of_range: If an index is not less than n.