export { Bag };

import * as MultiLayerMap from "../../util/MultiLayerMap.js";
import * as RandTools from "../../util/RandTools.js";

/**
 * A pool for number array which is created with sequence and randomized offset. It could reduce re-creating them of same parameters
 * again and again to improve performance.
 *
 */
class Bag extends MultiLayerMap.Base {

//!!! ...unfinished... (2022/05/23)
//   constructor() {
//     super();
//   }

  get_by_nPassThroughStyleId( inputChannelCount, outputChannelCount, inputChannelIndexStart, bBias, nPassThroughStyleId ) {

//!!! ...unfinished... (2022/05/23)
//     let nPassThroughStyleId = ValueDesc.PassThroughStyle.Singleton.Ids.PASS_THROUGH_STYLE_FILTER_1_BIAS_0;
//     const thePassThroughStyleInfo = ValueDesc.PassThroughStyle.Singleton.getInfoById( nPassThroughStyleId );

  }

  get_by_filterValue_biasValue( inputChannelCount, outputChannelCount, inputChannelIndexStart, bBias, filterValue = 1, biasValue = 0 ) {

//!!! ...unfinished... (2022/05/23)
    let by_outputChannelCount_inputChannelIndexStart_bBias_filterValue_biasValue
      = MapTools.get_or_create(
          this.by_inputChannelCount_outputChannelCount_inputChannelIndexStart_bBias_filterValue_biasValue, inputChannelCount );

  }

//!!! ...unfinished... (2022/05/23)
  /** Release all tensors. */
  disposeTensors() {
    if ( this.tensorsBy_originalHeight_originalWidth_channelCount_filterHeight_filterWidth_stridesPad ) {

      for ( let tensor
        of MapTools.values_recursively( this.tensorsBy_originalHeight_originalWidth_channelCount_filterHeight_filterWidth_stridesPad ) ) {

        tensor.dispose();
      }

      this.tensorsBy_originalHeight_originalWidth_channelCount_filterHeight_filterWidth_stridesPad.clear();
    }
  }

}

@@ -358,1404 +358,1017 @@
  %7B%0A%0A
-//!!! ...unfinished... (2022/05/23)%0A//   constructor() %7B%0A//     super();%0A//   %7D%0A%0A  get_by_nPassThroughSty
+  /**%0A   * Similar to Base.ensure_object_property_numberArray_length_fil
 le
-I
 d(
- inputChannelCount, outputChannelCount, inputChannelIndexStart, bBias, nPassThroughStyleId ) %7B%0A%0A//!!! ...unfinished... (2022/05/23)%0A//     let nPassThroughStyleId = ValueDesc.PassThroughStyle.Singleton.Ids.PASS_THROUGH_STYLE_FILTER_1_BIAS_0;%0A//     const thePassThroughStyleInfo = ValueDesc.PassThroughStyle.Singleton.getInfoById( nPassThroughStyleId );%0A%0A  %7D%0A%0A  get_by_filterValue_biasValue( inputChannelCount, outputChannelCount, inputChannelIndexStart, bBias, filterValue = 1, biasValue = 0 ) %7B%0A%0A//!!! ...unfinished... (2022/05/23)%0A    let by_outputChannelCount_inputChannelIndexStart_bBias_filterValue_biasValue%0A      = MapTools.get_or_create(%0A          this.by_inputChannelCount_outputChannelCount_inputChannelIndexStart_bBias_filterValue_biasValue, inputChannelCount );%0A%0A  %7D%0A%0A//!!! ...unfinished... (2022/05/23)%0A  /** Release all tensors. */%0A  disposeTensors() %7B%0A    if ( this.tensorsBy_originalHeight_originalWidth_channelCount_filterHeight_filterWidth_stridesPad
+). But the property will be a shared number array. Its value%0A   * may be shared with other caller.%0A   *%0A   * This may have better performance because of number array re-using (instead of re-generating).%0A   *%0A   *%0A   * @param %7Bobject%7D io_object        The object to be checked and modified.%0A   * @param %7Bstring%7D propertyName     The property io_object%5B propertyName %5D will be ensured as a number array.%0A   * @param %7Bnumber%7D elementCount     The property io_object%5B propertyName %5D.length will be ensured as elementCount.%0A   * @param %7Bnumber%7D randomOffsetMin  The random number offet lower bound.%0A   * @param %7Bnumber%7D randomOffsetMax  The random number offet upperer bound.%0A   */%0A  get_by_elementCount_randomOffsetMin_randomOffsetMax( elementCount, randomOffsetMin = 0, randomOffsetMax = 0
  ) %7B%0A
-%0A  
     
-for ( let tensor%0A        of MapTools.values_recursively( this.tensorsBy_originalHeight_originalWidth_channelCount_filterHeight_filterWidth_stridesPad ) ) %7B%0A%0A        tensor.dispose();%0A      %7D%0A%0A      this.tensorsBy_originalHeight_originalWidth_channelCount_filterHeight_filterWidth_stridesPad.clear();%0A    %7D
+return this.get_or_create_by_arguments1_etc(%0A      RandTools.generate_numberArray,%0A      elementCount, randomOffsetMin, randomOffsetMax );
 %0A  %7D

Update SequenceRandomArray.js