using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BCG { public class SparseVectorBlueTable : IBlueRowCollection { private List _rows = new List(50); public SparseVectorBlueTable(IBlueTableSchema schema) { this.schema = schema; } public void reserve(int length) { if (_rows.Capacity < length) { _rows.Capacity += 1024; } while (_rows.Count <= length) { _rows.Add(null); } } public IBlueRow this[int id] { get { return _rows[id]; } set { this.reserve(id); _rows[id] = value; } } public IBlueTableSchema schema { get; private set; } public bool containsID(int id) { return (id >= 0 && id < _rows.Count && this[id] != null); } public void CopyTo(Array array, int index) { _rows.CopyTo((IBlueRow[])array, index);} public int Count { get { return _rows.Count; } } public bool IsSynchronized {get { return false; }} public object SyncRoot { get { return this; } } public System.Collections.IEnumerator GetEnumerator() { return _rows.Where(r => r != null).GetEnumerator(); } } }