/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../chunks/_rollupPluginBabelHelpers","./arrayUtils","./HeapSort"],(function(t,i,h){"use strict";const n=1.5,s=1.1;function e(t){t.data.length>n*t.length&&(t.data.length=Math.floor(t.length*s))}return function(){function n(t){this.data=[],this._length=0,this._allocator=void 0,this._deallocator=()=>null,this._shrink=()=>{},this._hint=new i.PositionHint,t&&(t.initialSize&&(this.data=new Array(t.initialSize)),t.allocator&&(this._allocator=t.allocator),void 0!==t.deallocator&&(this._deallocator=t.deallocator),t.shrink&&(this._shrink=()=>e(this)))}var s=n.prototype;return s.toArray=function(){return this.data.slice(0,this.length)},s.filter=function(t){const i=new Array;for(let h=0;h<this._length;h++){const n=this.data[h];t(n)&&i.push(n)}return i},s.getItemAt=function(t){if(!(t<0||t>=this._length))return this.data[t]},s.includes=function(t,i){const h=this.data.indexOf(t,i);return-1!==h&&h<this.length},s.clear=function(){this.length=0},s.prune=function(){this.clear(),this.data=[]},s.push=function(t){this.data[this._length++]=t},s.pushArray=function(t,i=t.length){for(let h=0;h<i;h++)this.data[this._length++]=t[h]},s.fill=function(t,i){for(let h=0;h<i;h++)this.data[this._length++]=t},s.pushNew=function(){this._allocator&&(this.data[this.length]=this._allocator(this.data[this.length]));const t=this.data[this._length];return++this._length,t},s.unshift=function(t){this.data.unshift(t),this._length++,e(this)},s.pop=function(){if(0===this.length)return;const t=this.data[this.length-1];return this.length=this.length-1,this._shrink(),t},s.remove=function(t){const h=i.indexOf(this.data,t,this.length,this._hint);if(-1!==h)return this.data.splice(h,1),this.length=this.length-1,t},s.removeUnordered=function(t){const h=i.removeUnordered(this.data,t,this.length,this._hint);return void 0!==h&&(this.length=this.length-1),this._shrink(),h},s.removeUnorderedIndex=function(t){if(!(t>=this.length||t<0))return this.swapElements(t,this.length-1),this.pop()},s.removeUnorderedMany=function(t,h=t.length,n){this.length=i.removeUnorderedMany(this.data,t,this.length,h,this._hint,n),this._shrink()},s.front=function(){if(0!==this.length)return this.data[0]},s.back=function(){if(0!==this.length)return this.data[this.length-1]},s.swapElements=function(t,i){t>=this.length||i>=this.length||t===i||([this.data[t],this.data[i]]=[this.data[i],this.data[t]])},s.sort=function(t){h.sort(this.data,0,this.length,t)},s.iterableSort=function(t){return h.iterableSort(this.data,0,this.length,t)},s.some=function(t,i){for(let h=0;h<this.length;++h)if(t.call(i,this.data[h],h,this.data))return!0;return!1},s.filterInPlace=function(t,i){let h=0;for(let n=0;n<this._length;++n){const s=this.data[n];t.call(i,s,n,this.data)&&(this.data[n]=this.data[h],this.data[h]=s,h++)}if(this._deallocator)for(let n=h;n<this._length;n++)this.data[n]=this._deallocator(this.data[n]);return this._length=h,this._shrink(),this},s.forAll=function(t,i){const h=this.length,n=this.data;for(let s=0;s<h;++s)t.call(i,n[s],s,n)},s.forEach=function(t,i){for(let h=0;h<this.length;++h)t.call(i,this.data[h],h,this.data)},s.map=function(t,i){const h=new Array(this.length);for(let n=0;n<this.length;++n)h[n]=t.call(i,this.data[n],n,this.data);return h},s.reduce=function(t,i){let h=i;for(let n=0;n<this.length;++n)h=t(h,this.data[n],n,this.data);return h},s.has=function(t){const i=this.length,h=this.data;for(let n=0;n<i;++n)if(h[n]===t)return!0;return!1},t._createClass(n,[{key:"length",get:function(){return this._length},set:function(t){if(t>this._length){if(this._allocator){for(;this._length<t;)this.data[this._length++]=this._allocator(this.data[this._length]);return}this._length=t}else{if(this._deallocator)for(let i=t;i<this._length;++i)this.data[i]=this._deallocator(this.data[i]);this._length=t,this._shrink()}}}]),n}()}));
