#region File Description //----------------------------------------------------------------------------- // BatchRemovalCollection.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using System.Collections.Generic; #endregion namespace NetRumble { /// /// A collection with an additional feature to isolate the /// removal of the objects. /// public class BatchRemovalCollection : List { #region Pending Removal Data /// /// The list of objects to be removed on the next ApplyPendingRemovals(). /// private List pendingRemovals; #endregion #region Initialization /// /// Constructs a new collection. /// public BatchRemovalCollection() { pendingRemovals = new List(); } #endregion #region Collection /// /// Queue an item for removal. /// /// public void QueuePendingRemoval(T item) { pendingRemovals.Add(item); } /// /// Remove all of the "garbage" objects from this collection. /// public void ApplyPendingRemovals() { for (int i = 0; i < pendingRemovals.Count; i++) { Remove(pendingRemovals[i]); } pendingRemovals.Clear(); } #endregion } }