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

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

//**************************************************************************************************
partial class HArray {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
/// <exception cref="ArgumentException" />
public static int GetJuggedArrayUniformLength<T>(T[][] array)
{
   HArrayArgChecking.VerifyUniformLengthJuggedArray( array );
   return array.Length > 0 ? array[ 0 ].Length : 0;
}

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

/// <exception cref="ArgumentNullException" />
public static T[][] DuplicateJuggedArray<T>(T[][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][] DuplicateJuggedArray<T>(T[][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][][] DuplicateJuggedArray<T>(T[][][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][][][] DuplicateJuggedArray<T>(T[][][][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][][][][] DuplicateJuggedArray<T>(T[][][][][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][][][][][] DuplicateJuggedArray<T>(T[][][][][][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][][][][][][] DuplicateJuggedArray<T>(T[][][][][][][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][][][][][][][] DuplicateJuggedArray<T>(T[][][][][][][][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

/// <exception cref="ArgumentNullException" />
[CLSCompliant(false)]
public static T[][][][][][][][][][] DuplicateJuggedArray<T>(T[][][][][][][][][][] array)
{
   array = Duplicate( array );
   foreach (int idx in IndexEnumeration( array ))
      array[ idx ] = DuplicateJuggedArrayOrNull( array[ idx ] );
   return array;
}

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

[HOptionalResult]
public static T[][] DuplicateJuggedArrayOrNull<T>([HOptional] T[][] array)
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][] DuplicateJuggedArrayOrNull<T>([HOptional] T[][][] array)
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][][] DuplicateJuggedArrayOrNull<T>([HOptional] T[][][][] array)
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][][][] DuplicateJuggedArrayOrNull<T>([HOptional] T[][][][][] array)
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][][][][] DuplicateJuggedArrayOrNull<T>([HOptional] T[][][][][][] array)
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][][][][][] DuplicateJuggedArrayOrNull<T>([HOptional] T[][][][][][][] array)
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][][][][][][] DuplicateJuggedArrayOrNull<T>([HOptional] T[][][][][][][][] array)
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][][][][][][][] DuplicateJuggedArrayOrNull<T>( [HOptional]
                                                                 T[][][][][][][][][] array )
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

[HOptionalResult][CLSCompliant(false)]
public static T[][][][][][][][][][] DuplicateJuggedArrayOrNull<T>( [HOptional]
                                                                   T[][][][][][][][][][] array )
{
   return array!=null ? DuplicateJuggedArray( array ) : null;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HArray
//**************************************************************************************************

} // CommonHelpers (.WASM)
