//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
/// <summary>
/// </summary>
partial class HFromOneListIndexer<T> {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public HFromOneListIndexer<T> GetRange(int oneBasedIdx,int count)
{
   return Access(delegate{
      return new HFromOneListIndexer<T>( _List_.GetRange( oneBasedIdx-1, count ) );
   });
}

public HFromOneListIndexer<TOutput> ConvertAll<TOutput>(Converter<T,TOutput> converter)
{
   return Access(delegate{
      return new HFromOneListIndexer<TOutput>( _List_.ConvertAll( converter ) );
   });
}

//==================================================================================================

public List<T>.Enumerator GetEnumerator()
{
   return Access(delegate{
      return _List_.GetEnumerator();
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public void Clear()
{
   Access(true,delegate{
      _List_.Clear();
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public void TrimExcess()
{
   Access(true,delegate{
      _List_.TrimExcess();
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public void Add(T item)
{
   Access(true,delegate{
      _List_.Add( item );
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public void AddRange(IEnumerable<T> collection)
{
   Access(true,delegate{
      _List_.AddRange( collection );
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public void Insert(int oneBasedIdx,T item)
{
   Access(true,delegate{
      _List_.Insert( oneBasedIdx-1, item );
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public void RemoveAt(int oneBasedIdx)
{
   Access(true,delegate{
      _List_.RemoveAt( oneBasedIdx-1 );
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public int RemoveAll(Predicate<T> match)
{
   return Access(true,delegate{
      return _List_.RemoveAll( match );
   });
}

/// <exception cref="HReadonlyObjectAccessException" />
public void RemoveRange(int oneBasedIdx,int count)
{
   Access(true,delegate{
      _List_.RemoveRange( oneBasedIdx-1, count );
   });
}

public bool Contains(T item)
{
   return Access(delegate{
      return _List_.Contains( item );
   });
}

public bool Exists(Predicate<T> match)
{
   return Access(delegate{
      return _List_.Exists( match );
   });
}

public T Find(Predicate<T> match)
{
   return Access(delegate{
      return _List_.Find( match );
   });
}

public bool TrueForAll(Predicate<T> match)
{
   return Access(delegate{
      return _List_.TrueForAll( match );
   });
}

public void ForEach(Action<T> action)
{
   Access(delegate{
      _List_.ForEach( action );
   });
}

public List<T> FindAll(Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindAll( match );
   });
}

public T FindLast(Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindLast( match );
   });
}

public T[] ToArray()
{
   return Access(delegate{
      return _List_.ToArray();
   });
}

//==================================================================================================

public int BinarySearch(T item)
{
   return Access(delegate{
      return _List_.BinarySearch( item ) + 1;
   });
}
public int BinarySearch(T item,IComparer<T> comparer)
{
   return Access(delegate{
      return _List_.BinarySearch( item, comparer ) + 1;
   });
}
public int BinarySearch(int oneBasedIdx,int count,T item,IComparer<T> comparer)
{
   return Access(delegate{
      return _List_.BinarySearch( oneBasedIdx-1, count, item, comparer ) + 1;
   });
}

//--------------------------------------------------------------------------------------------------

public int IndexOf(T item)
{
   return Access(delegate{
      return _List_.IndexOf( item ) + 1;
   });
}
public int IndexOf(T item,int oneBasedIdx)
{
   return Access(delegate{
      return _List_.IndexOf( item, oneBasedIdx-1 ) + 1;
   });
}
public int IndexOf(T item,int oneBasedIdx,int count)
{
   return Access(delegate{
      return _List_.IndexOf( item, oneBasedIdx-1, count ) + 1;
   });
}

//--------------------------------------------------------------------------------------------------

public int FindIndex(Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindIndex( match ) + 1;
   });
}
public int FindIndex(int oneBasedStartIdx,Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindIndex( oneBasedStartIdx-1, match ) + 1;
   });
}
public int FindIndex(int oneBasedStartIdx,int count,Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindIndex( oneBasedStartIdx-1, count, match ) + 1;
   });
}

//--------------------------------------------------------------------------------------------------

public int FindLastIndex(Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindLastIndex( match ) + 1;
   });
}
public int FindLastIndex(int oneBasedStartIdx,Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindLastIndex( oneBasedStartIdx-1, match ) + 1;
   });
}
public int FindLastIndex(int oneBasedStartIdx,int count,Predicate<T> match)
{
   return Access(delegate{
      return _List_.FindLastIndex( oneBasedStartIdx-1, count, match ) + 1;
   });
}

//--------------------------------------------------------------------------------------------------

public int LastIndexOf(T item)
{
   return Access(delegate{
      return _List_.LastIndexOf( item ) + 1;
   });
}
public int LastIndexOf(T item,int oneBasedIdx)
{
   return Access(delegate{
      return _List_.LastIndexOf( item, oneBasedIdx-1 ) + 1;
   });
}
public int LastIndexOf(T item,int oneBasedIdx,int count)
{
   return Access(delegate{
      return _List_.LastIndexOf( item, oneBasedIdx-1, count ) + 1;
   });
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="HReadonlyObjectAccessException" />
public void Reverse()
{
   Access(true,delegate{
      _List_.Reverse();
   });
}
/// <exception cref="HReadonlyObjectAccessException" />
public void Reverse(int oneBasedIdx,int count)
{
   Access(true,delegate{
      _List_.Reverse( oneBasedIdx-1, count );
   });
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="HReadonlyObjectAccessException" />
public void Sort()
{
   Access(true,delegate{
      _List_.Sort();
   });
}
/// <exception cref="HReadonlyObjectAccessException" />
public void Sort(Comparison<T> comparison)
{
   Access(true,delegate{
      _List_.Sort( comparison );
   });
}
/// <exception cref="HReadonlyObjectAccessException" />
public void Sort(IComparer<T> comparer)
{
   Access(true,delegate{
      _List_.Sort( comparer );
   });
}
/// <exception cref="HReadonlyObjectAccessException" />
public void Sort(int oneBasedIdx,int count,IComparer<T> comparer)
{
   Access(true,delegate{
      _List_.Sort( oneBasedIdx-1, count, comparer );
   });
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HFromOneListIndexer
//**************************************************************************************************

} // CommonHelpers (.WASM)
