UNPKG

@hashgraph/sdk

Version:
3 lines (2 loc) 884 B
class t{constructor(){this.list=[],this.locked=!1,this.index=0}setList(t){if(this.locked)throw new Error("list is locked");return this.list=t,this.index=0,this}push(...t){if(this.locked)throw new Error("list is locked");return this.list.push(...t),this}setLocked(){return this.locked=!0,this}clear(){this.list=[],this.index=0,this.locked=!1}get(t){return this.list[t]}set(t,s){return t===this.length?this.list.push(s):this.list[t]=s,this}setIfAbsent(t,s){return t!=this.length&&null!=this.list[t]||this.set(t,s()),this}get next(){return this.get(this.advance())}get current(){return this.get(this.index)}advance(){const t=this.index;return this.index=(this.index+1)%this.list.length,t}get isEmpty(){return 0===this.length}get length(){return this.list.length}clone(){const s=new t;return s.list=this.list,s.locked=this.locked,s}}export{t as default}; //# sourceMappingURL=List.js.map