Swap and erase elements

What is it about?

This page describes the Swap and Erase node of the Scene Nodes system in Cinema 4D. It deletes entries by moving end elements into the gaps and truncating — fast removal where element order doesn't matter.

This Node can be used to remove elements from an Array. This copies elements from the end of the Array to the deleted element positions and truncates the Array to fit in accordance with the number of deleted elements. To illustrate, let's imagine an Array of values 1, 2, 3, 4, and 5. We use the Node to remove the first two elements, i.e., the values 1 and 2, from the Array. This moves the last two values, 4 and 5, to the beginning of the Array and the array is shortened by two entries at the end. The resulting Array contains these values: 4, 5, 3.
The function is similar to that of the Delete Elements Node, but can be processed somewhat faster, since the reordering of the elements is omitted here.