Why is RemoveAt( 0 ) slow?

Every item behind it has to move up.

Why is RemoveAt( 0 ) slow?

The problem

Take one, everybody shuffles.

List<Wave> _waves = LoadWaves(); void NextWave(){    var wave = _waves[0];    _waves.RemoveAt( 0 );    Spawn( wave );}

RemoveAt( 0 ) copies every remaining item one slot left. A long list pays for it every time.

The fix

Use a line, not a list.

A Queue is first in, first out. Taking from the front costs the same, however long it gets.

Enqueue→back of the line
Dequeue→front of the line

The fix in code

In at the back, out at the front.

Queue<Wave> _waves = new( LoadWaves() ); void NextWave(){    if ( _waves.TryDequeue( out var wave ) )        Spawn( wave );}

TryDequeue also covers the empty case, so the last wave can't crash it.

Same shape

Anything that waits its turn.

If things are handled in the order they arrive, it's a queue.

Spawn waves
Queue
Dialogue lines
Queue
Undo history
Stack, last in first out

The rule

Taking from the front? Use a Queue.

Add
Enqueue( x )
Take the next
TryDequeue( out x )
Last in, first out
Stack<T>