using System.Collections.Generic; namespace bbiwarg.Recognition.Tracking { /// /// Generates unique IDs and keeps track of the currently used IDs. /// public class TrackIDPool { /// /// the currently used IDs /// private List usedIDs; /// /// Initializes a new instance of the TrackIDPool class. /// public TrackIDPool() { usedIDs = new List(); } /// /// Returns the next unused (lowest) ID. /// /// the next unused ID public int getNextUnusedID() { int id = 1; while (usedIDs.Contains(id)) id++; usedIDs.Add(id); return id; } /// /// Removes the given ID from the used IDs. /// /// the unused ID public void setIDUnused(int id) { usedIDs.Remove(id); } } }