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

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

/// <summary>
/// List-based set of elements for value element type (with deterministic order)
/// </summary>
public class ListSetV<TElement>: ListSet<TElement>
where TElement: struct, IEquatable<TElement> {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public new bool Contains( TElement value ) =>
   BaseList.Contains( value );

public new bool Include( TElement value )
{
   if ( BaseList.Contains( value ) )
      return false;
   BaseList.Add( value );
   return true;
}

public new bool Exclude( TElement value ) =>
   BaseList.RemoveAll( val => val.Equals(value) ) > 0;

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

public new void IncludeValues( IEnumerable<TElement> values )
{
   foreach ( var value in values )
      if ( !BaseList.Contains( value ) )
         BaseList.Add( value );
}

public new void ExcludeValues( IEnumerable<TElement> values )
{
   foreach ( var value in values )
      BaseList.RemoveAll( val => val.Equals(value) );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // ListSetV

} // user_rtx (.wasm)
