Files
spark/src/DataStreamSuite/DataStreamCore/BlueData/BlueColumnValueCollection.cs
T

35 lines
918 B
C#

#nullable enable
namespace Bts.DataStreamCore;
using BCG;
using Spark.Core.Collections;
using System;
using System.Collections.Generic;
public static class BlueColumnValueCollection {
public static BlueColumnValueCollection<T> Create<T>(IBlueRowCollection rows, int columnIndex, Func<object?, T> convert) =>
new(rows, columnIndex, convert);
}
public class BlueColumnValueCollection<T> : IMutableCollectionFacade<T> {
readonly IBlueRowCollection rows;
readonly int columnIndex;
readonly Func<object?, T> convert;
public BlueColumnValueCollection(IBlueRowCollection rows, int columnIndex, Func<object?, T> convert) {
this.rows = rows;
this.columnIndex = columnIndex;
this.convert = convert;
}
public int Count => rows.Count;
public IEnumerator<T> GetEnumerator() {
foreach (IBlueRow r in rows) {
yield return convert(r[columnIndex]);
}
}
}