66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
|
|
namespace BCG
|
|
{
|
|
/// <summary>
|
|
/// Optimized for the scneario when id's are sequential starting from 0 (no indexing is necessary etc)
|
|
/// </summary>
|
|
public class SequentialIDBlueTable : IBlueRowCollection
|
|
{
|
|
private IBlueRow[] myRows;
|
|
private IBlueTableSchema mySchema;
|
|
|
|
/// <summary>
|
|
/// The refernce to the rows is kept. So if user wants to reuse the variable, its best
|
|
/// to pass in a copied value
|
|
/// </summary>
|
|
/// <param name="schema"></param>
|
|
/// <param name="rows"></param>
|
|
public SequentialIDBlueTable (IBlueTableSchema schema, IBlueRow[] rows)
|
|
{
|
|
myRows = rows;
|
|
mySchema = schema;
|
|
}
|
|
|
|
public SequentialIDBlueTable(IBlueTableSchema schema, System.Collections.Generic.IReadOnlyList<object[]> 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
|
|
}
|
|
}
|