using Svelto.DataStructures; using System.Collections.Generic; namespace Svelto.ECS.Internal { /// /// This is just a place holder at the moment /// I always wanted to create my own Dictionary /// data structure as excercise, but never had the /// time to. At the moment I need the custom interface /// wrapped though. /// public interface ITypeSafeDictionary { void FillWithIndexedEntityViews(ITypeSafeList entityViews); bool Remove(int entityId); IEntityView GetIndexedEntityView(int entityID); } class TypeSafeDictionary : Dictionary, ITypeSafeDictionary where TValue:IEntityView { internal static readonly ReadOnlyDictionary Default = new ReadOnlyDictionary(new Dictionary()); public void FillWithIndexedEntityViews(ITypeSafeList entityViews) { int count; var buffer = FasterList.NoVirt.ToArrayFast((FasterList) entityViews, out count); for (int i = 0; i < count; i++) { var entityView = buffer[i]; Add(entityView.ID, entityView); } } new public bool Remove(int entityId) { base.Remove(entityId); return this.Count > 0; } public IEntityView GetIndexedEntityView(int entityID) { return this[entityID]; } } }