public ComputerCpu(double maxDt, double a, double omega)
: base(maxDt, a, omega)
{
// 粒子群を初期化
this.particles = new Particle[0];
// 準備処理は何もしない
this.prepare = () => { };
// 粒子が追加された時に
base.ParticleAdded += (sender, e) =>
{
// 準備処理の時の処理を実装
this.prepare = () =>
{
// 新しい粒子群配列を生成
var newParticles = new Particle[this.particles.Length + this.inputParticles.Count];
// 古い粒子群を新しい粒子群に複製
this.particles.CopyTo(newParticles, 0);
// 入力粒子群を新しい粒子群に複製
this.inputParticles.CopyTo(newParticles, this.particles.Length);
// 新しい粒子群を今の粒子群とする
this.particles = newParticles;
// 入力粒子群を空にする
this.inputParticles.Clear();
// 準備処理は空
this.prepare = () => { };
};
};
}