Array Manipulation in Hardness Test (Buff System)

Hi,

i am now at a point where i wanna create a buff system.

All the buffs that affects a character shall be stored in an array.

Whenever the character use a skill or will be hit a buff or debuff will be added to the array.

Meanwhile another function use the array to substract the elapsed time and when the time is at zero, the buff/debuff element will be removed from the array.

These processes happens per tick.

In the end the array becomes corrupted cause adding elements and changing/removing elements does not work well at the same time.

Does anyone has experience about that? Keeping arrays stable even when different functions working on it.

thanks in advance

raidfire.net