export { ChannelPartInfo };
export { ChannelPartInfoPool };
export { FiltersBiasesPartInfo };
export { FiltersBiasesPartInfoPool };

import * as Pool from "../../util/Pool.js";

/**
 * Half channels information. Describe channel index range of lower half or higher half.
 *
 *
 * @member {number} inputChannelCount
 *   This ChannelPart includes how many input channels.
 *
 * @member {number} effectFilterY_passThrough, effectFilterX_passThrough
 *   For pass-through filters, there is only one position (inside the effect depthwise filter) with non-zero value. All other
 * positions of the filters should be zero.
 *   - Note: Unfortunately, the pass-through feature may not work for ( dilation > 1 ) because the non-zero-filter-value might
 *       be just at the dilation position which does not exist in a filter. So, only ( dilation == 1 ) is supported.
 *   - Negative value means this part is not for pass-through.
 *
 * @member {boolean} bPassThrough
 *   If true, this is the half channels for pass-through input to output.
 */
class ChannelPartInfo {

  /**
   */
  constructor( inputChannelCount, effectFilterY_passThrough = -1, effectFilterX_passThrough = -1 ) {
    this.setAsConstructor( inputChannelCount, effectFilterY_passThrough, effectFilterX_passThrough );
  }

  /**
   * @return {ChannelPartInfo}
   *   Return the this object.
   */
  setAsConstructor( inputChannelCount, effectFilterY_passThrough = -1, effectFilterX_passThrough = -1 ) {
    this.inputChannelCount = inputChannelCount;
    this.effectFilterY_passThrough = effectFilterY_passThrough;
    this.effectFilterX_passThrough = effectFilterX_passThrough;

    this.bPassThrough = ( ( this.effectFilterY_passThrough >= 0 ) && ( this.effectFilterX_passThrough >= 0 ) );
    return this;
  }

  /**
   * After calling this method, this object should be viewed as disposed and should not be operated again.
   */
  disposeResources_and_recycleToPool() {
    //this.disposeResources();
    ChannelPartInfoPool.Singleton.recycle( this );
  }

  /**
   * @return {boolean} Return true, if the specified position should be non-zero for pass-through input to output.
   */
  isPassThrough_FilterPosition_NonZero( effectFilterY, effectFilterX ) {
    if ( ( effectFilterY == this.effectFilterY_passThrough ) && ( effectFilterX == this.effectFilterX_passThrough ) )
      return true;
    return false;
  }      
}


/**
 * Providing ChannelPartInfo.
 *
 */
class ChannelPartInfoPool extends Pool.Root {

  constructor() {
    super( "Depthwise.ChannelPartInfoPool", ChannelPartInfo, ChannelPartInfo.setAsConstructor );
  }

}

/**
 * Used as default Depthwise.ChannelPartInfo provider.
 */
ChannelPartInfoPool.Singleton = new ChannelPartInfoPool();


/**
 * Describe a range for a (depthwise) filters and a biases.
 *
 *
 * @member {ChannelPartInfo[]} aChannelPartInfoArray
 *   Every input-output relationship of this parts.
 *
 */
class FiltersBiasesPartInfo {

  /**
   *
   */
  constructor( aChannelPartInfoArray ) {
    this.aChannelPartInfoArray = aChannelPartInfoArray;
  }

  /**
   *
   * @return {FiltersBiasesPartInfo}
   *   Return the this object.
   */
  setAsConstructor( aChannelPartInfoArray ) {
    this.aChannelPartInfoArray = aChannelPartInfoArray;
    return this;
  }

  /**
   * After calling this method, this object should be viewed as disposed and should not be operated again.
   */
  disposeResources_and_recycleToPool() {
    //this.disposeResources();
    FiltersBiasesPartInfoPool.Singleton.recycle( this );
  }

}


/**
 * Providing FiltersBiasesPartInfo.
 *
 */
class FiltersBiasesPartInfoPool extends Pool.Root {

  constructor() {
    super( "Depthwise.FiltersBiasesPartInfoPool", FiltersBiasesPartInfo, FiltersBiasesPartInfo.setAsConstructor );
  }

}

/**
 * Used as default Depthwise.FiltersBiasesPartInfo provider.
 */
FiltersBiasesPartInfoPool.Singleton = new FiltersBiasesPartInfoPool();


@@ -1174,20 +1174,31 @@
 ) %7B%0A    
-this
+ChannelPartInfo
 .setAsCo
@@ -1198,33 +1198,44 @@
 setAsConstructor
-(
+.call( this,
  inputChannelCou
@@ -1297,32 +1297,109 @@
 h );%0A  %7D%0A%0A  /**%0A
+   * @param %7BChannelPartInfo%7D this%0A   *   The object to be initialized.%0A   *%0A
    * @return %7BCh
@@ -1444,32 +1444,39 @@
 object.%0A   */%0A  
+static 
 setAsConstructor
@@ -1866,32 +1866,369 @@
 turn this;%0A  %7D%0A%0A
+  /**%0A   * Sub-class should override this method (and call super.disposeResources() before return).%0A   */%0A  disposeResources() %7B%0A    this.bPassThrough = undefined;%0A    this.effectFilterX_passThrough = undefined;%0A    this.effectFilterY_passThrough = undefined;%0A    this.inputChannelCount = undefined;%0A    //super.disposeResources();%0A  %7D%0A%0A
   /**%0A   * After
@@ -2367,34 +2367,32 @@
 eToPool() %7B%0A    
-//
 this.disposeReso
@@ -3499,24 +3499,107 @@
 %0A  /**%0A   *%0A
+   * @param %7BFiltersBiasesPartInfo%7D this%0A   *   The object to be initialized.%0A   *%0A
    * @return
@@ -3662,16 +3662,23 @@
    */%0A  
+static 
 setAsCon
@@ -3783,32 +3783,329 @@
 turn this;%0A  %7D%0A%0A
+  /**%0A   * Sub-class should override this method (and call super.disposeResources() before return).%0A   */%0A  disposeResources() %7B%0A    this.aChannelPartInfoArray = null; // Because the array is not created by this FiltersBiasesPartInfo, do not recyclye it here.%0A    //super.disposeResources();%0A  %7D%0A%0A
   /**%0A   * After
@@ -4252,18 +4252,16 @@
 ) %7B%0A    
-//
 this.dis

Update Depthwise_ChannelPartInfo.js