using System; using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; namespace imm; public record class List : Timed>, IImmutableList { ImmutableList Values = ImmutableList.Empty; public T this[int index] => (( IReadOnlyList )Values)[index]; public int Count => Values.Count; public List Add( T value ) { return this with { Values = Values.Add( value ) }; } public List AddRange( IEnumerable items ) { return this with { Values = Values.AddRange( items ) }; } public List Clear() { return this with { Values = Values.Clear() }; } public IEnumerator GetEnumerator() { return Values.GetEnumerator(); } public int IndexOf( T item, int index, int count, IEqualityComparer equalityComparer ) { return Values.IndexOf( item, index, count, equalityComparer ); } public int IndexOf( T item ) { return Values.IndexOf( item, 0, Count, EqualityComparer.Default ); } public List Insert( int index, T element ) { return this with { Values = Values.Insert( index, element ) }; } public List InsertRange( int index, IEnumerable items ) { return this with { Values = Values.InsertRange( index, items ) }; } public int LastIndexOf( T item, int index, int count, IEqualityComparer equalityComparer ) { return Values.LastIndexOf( item, index, count, equalityComparer ); } public List Remove( T value ) { return Remove( value, EqualityComparer.Default ); } public List Remove( T value, IEqualityComparer equalityComparer ) { return this with { Values = Values.Remove( value, equalityComparer ) }; } public List RemoveAll( Predicate match ) { return this with { Values = Values.RemoveAll( match ) }; } public List RemoveAt( int index ) { return this with { Values = Values.RemoveAt( index ) }; } public List RemoveRange( IEnumerable items, IEqualityComparer equalityComparer ) { return this with { Values = Values.RemoveRange( items, equalityComparer ) }; } public List RemoveRange( int index, int count ) { return this with { Values = Values.RemoveRange( index, count ) }; } public List Replace( T oldValue, T newValue, IEqualityComparer equalityComparer ) { return this with { Values = Values.Replace( oldValue, newValue, equalityComparer ) }; } public List SetItem( int index, T value ) { return this with { Values = Values.SetItem( index, value ) }; } IEnumerator IEnumerable.GetEnumerator() { return (( IEnumerable )Values).GetEnumerator(); } IImmutableList IImmutableList.Clear() { return Clear(); } IImmutableList IImmutableList.Add( T value ) { return Add( value ); } IImmutableList IImmutableList.AddRange( IEnumerable items ) { return AddRange( items ); } IImmutableList IImmutableList.Insert( int index, T element ) { return Insert( index, element ); } IImmutableList IImmutableList.InsertRange( int index, IEnumerable items ) { return InsertRange( index, items ); } IImmutableList IImmutableList.Remove( T value, IEqualityComparer equalityComparer ) { return Remove( value, equalityComparer ); } IImmutableList IImmutableList.RemoveAll( Predicate match ) { return RemoveAll( match ); } IImmutableList IImmutableList.RemoveAt( int index ) => RemoveAt( index ); IImmutableList IImmutableList.RemoveRange( IEnumerable items, IEqualityComparer equalityComparer ) => RemoveRange( items, equalityComparer ); IImmutableList IImmutableList.RemoveRange( int index, int count ) => RemoveRange( index, count ); IImmutableList IImmutableList.Replace( T oldValue, T newValue, IEqualityComparer equalityComparer ) => Replace( oldValue, newValue, equalityComparer ); IImmutableList IImmutableList.SetItem( int index, T value ) => SetItem( index, value ); }