public Sequence(FasterReadOnlyList <T> itemsToSort) { _ordered = FasterList <T> .PreInit((uint)SequenceCache <En> .cachedEnum.Count); var counted = 0; var cachedEnum = SequenceCache <En> .cachedEnum; foreach (var item in itemsToSort) { var type = item.GetType(); Check.Require(type.IsDefined(typeof(SequencedAttribute)) , $"Sequenced item not tagged as Sequenced {type.Name}"); var typeName = type.GetCustomAttribute <SequencedAttribute>().name; Check.Require(cachedEnum.ContainsKey(typeName) , $"Sequenced item not contained in the sequence {typeof(En).Name}: {typeName}"); var index = cachedEnum[typeName]; counted++; Check.Require(_ordered[index] == null , $"Items to sequence contains duplicate, {typeName} (wrong sequenced attribute name?)"); _ordered[index] = item; } #if DEBUG && !PROFILE_SVELTO if (counted != cachedEnum.Count) { var debug = new HashSet <string>(); foreach (var debugItem in itemsToSort) { debug.Add(debugItem.GetType().GetCustomAttribute <SequencedAttribute>().name); } foreach (var debugSequence in cachedEnum.Keys) { if (debug.Contains(debugSequence) == false) { throw new Exception( $"The sequence {typeof(En).Name} wasn't fully satisfied, missing sequenced item {debugSequence}"); } } } #endif }