using System; using System.Collections; namespace BCG { /// /// Optimized for the scneario when id's are sequential starting from 0 (no indexing is necessary etc) /// public class SequentialIDBlueTable : IBlueRowCollection { private IBlueRow[] myRows; private IBlueTableSchema mySchema; /// /// The refernce to the rows is kept. So if user wants to reuse the variable, its best /// to pass in a copied value /// /// /// public SequentialIDBlueTable (IBlueTableSchema schema, IBlueRow[] rows) { myRows = rows; mySchema = schema; } public SequentialIDBlueTable(IBlueTableSchema schema, System.Collections.Generic.IReadOnlyList rows) { mySchema = schema; myRows = new IBlueRow[rows.Count]; for (int i = 0; i < myRows.Length; i++) myRows[i] = new BlueRow(mySchema, rows[i]); } #region IBlueRowCollection Members public IBlueRow this[int id] { get { return myRows[id]; } } public IBlueTableSchema schema {get {return mySchema;}} public bool containsID (int id) { return id > -1 && id < myRows.Length; } #endregion #region ICollection Members public bool IsSynchronized {get {return false;}} public int Count {get {return myRows.Length;}} public void CopyTo (Array array, int index) {myRows.CopyTo (array, index);} public object SyncRoot {get {return null;}} #endregion #region IEnumerable Members public System.Collections.IEnumerator GetEnumerator() {return myRows.GetEnumerator ();} #endregion } }