using RhythmBase.Events;
namespace RhythmBase.Components
{
///
/// Represents a collection of ordered events.
///
/// The type of event.
public class OrderedEventCollection : OrderedEventCollection, ICollection where TEvent : IBaseEvent
{
///
/// Initializes a new instance of the class.
///
public OrderedEventCollection()
{
}
///
/// Initializes a new instance of the class with the specified items.
///
/// The items to add to the collection.
public OrderedEventCollection(IEnumerable items)
{
foreach (TEvent item in items)
Add(item);
}
///
/// Concatenates all events in the collection.
///
/// An that contains all events in the collection.
public new IEnumerable ConcatAll() => eventsBeatOrder.SelectMany(i => i.Value).Cast();
///
/// Adds an event to the collection.
///
/// The event to add.
public virtual void Add(TEvent item) => Add((IBaseEvent)(object)item);
///
public virtual bool Contains(TEvent item) => Contains((IBaseEvent)(object)item);
///
public void CopyTo(TEvent[] array, int arrayIndex) => CopyTo((IBaseEvent[])(object)array, arrayIndex);
///
public virtual bool Remove(TEvent item) => Remove((BaseEvent)(object)item);
///
public override string ToString() => string.Format("Count = {0}", Count);
///
IEnumerator IEnumerable.GetEnumerator()
{
foreach (KeyValuePair> pair in eventsBeatOrder)
foreach (TEvent item in pair.Value.Select(v => (TEvent)v))
yield return item;
}
}
}