/**
 * Copyright(c) Live2D Inc. All rights reserved.
 *
 * Use of this source code is governed by the Live2D Open Software license
 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
 */ /**
 * ベクター型（可変配列型）
 */ export class csmVector < T > { param iniitalCapacity param zeroClear constructor ( initialCapacity = 0 ) { if ( initialCapacity < 1 ) { this . _ptr = [ ] ; this . _capacity = 0 ; this . _size = 0 ; } else { this . _ptr = new Array ( initialCapacity ) ; this . _capacity = initialCapacity ; this . _size = 0 ; } } /**
     * インデックスで指定した要素を返す
     */ public at ( index ) { return this . _ptr [ index ] ; } param index param value public set ( index , value ) { this . _ptr [ index ] = value ; } /**
     * コンテナを取得する
     */ public get ( offset = 0 ) { const ret = new Array < T > ( ) ; for ( let i = offset ; i < this . _size ; i ++ ) { ret . push ( this . _ptr [ i ] ) ; } return ret ; } param value public pushBack ( value ) { if ( this . _size >= this . _capacity ) { this . prepareCapacity ( this . _capacity == 0 ? csmVector . s_defaultSize : this . _capacity * 2 ) ; } this . _ptr [ this . _size ++ ] = value ; } /**
     * コンテナの全要素を解放する
     */ public clear ( ) { this . _ptr . length = 0 ; this . _size = 0 ; } return public getSize ( ) { return this . _size ; } param newSize param value public assign ( newSize , value ) { const curSize = this . _size ; if ( curSize < newSize ) { this . prepareCapacity ( newSize ) ; } for ( let i = 0 ; i < newSize ; i ++ ) { this . _ptr [ i ] = value ; } this . _size = newSize ; } /**
     * サイズ変更
     */ public resize ( newSize , value = null ) { this . updateSize ( newSize , value , true ) ; } /**
     * サイズ変更
     */ public updateSize ( newSize , value = null , callPlacementNew = true ) { const curSize = this . _size ; if ( curSize < newSize ) { this . prepareCapacity ( newSize ) ; if ( callPlacementNew ) { for ( let i = this . _size ; i < newSize ; i ++ ) { if ( typeof value == 'function' ) { this . _ptr [ i ] = JSON . parse ( JSON . stringify ( new value ( ) ) ) ; } else { this . _ptr [ i ] = value ; } } } else { for ( let i = this . _size ; i < newSize ; i ++ ) { this . _ptr [ i ] = value ; } } } else { const sub = this . _size - newSize ; this . _ptr . splice ( this . _size - sub , sub ) ; } this . _size = newSize ; } param position param begin param end public insert ( position , begin , end ) { let dstSi = position . _index ; const srcSi = begin . _index ; const srcEi = end . _index ; const addCount = srcEi - srcSi ; this . prepareCapacity ( this . _size + addCount ) ; const addSize = this . _size - dstSi ; if ( addSize > 0 ) { for ( let i = 0 ; i < addSize ; i ++ ) { this . _ptr . splice ( dstSi + i , 0 , null ) ; } } for ( let i = srcSi ; i < srcEi ; i ++ , dstSi ++ ) { this . _ptr [ dstSi ] = begin . _vector . _ptr [ i ] ; } this . _size = this . _size + addCount ; } param index return return public remove ( index ) { if ( index < 0 || this . _size <= index ) { return false ; } this . _ptr . splice ( index , 1 ) ; -- this . _size ; return true ; } param ite public erase ( ite ) { const index = ite . _index ; if ( index < 0 || this . _size <= index ) { return ite ; } this . _ptr . splice ( index , 1 ) ; -- this . _size ; const ite2 = new iterator < T > ( this , index ) ; return ite2 ; } param newSize public prepareCapacity ( newSize ) { if ( newSize > this . _capacity ) { if ( this . _capacity == 0 ) { this . _ptr = new Array ( newSize ) ; this . _capacity = newSize ; } else { this . _ptr . length = newSize ; this . _capacity = newSize ; } } } /**
     * コンテナの先頭要素を返す
     */ public begin ( ) { const ite = this . _size == 0 ? this . end ( ) : new iterator < T > ( this , 0 ) ; return ite ; } /**
     * コンテナの終端要素を返す
     */ public end ( ) { const ite = new iterator < T > ( this , this . _size ) ; return ite ; } public getOffset ( offset ) { const newVector = new csmVector < T > ( ) ; newVector . _ptr = this . get ( offset ) ; newVector . _size = this . get ( offset ) . length ; newVector . _capacity = this . get ( offset ) . length ; return newVector ; } _ptr : T [ ] ; _size : number ; _capacity : number ; static readonly s_defaultSize = 10 ; } export class iterator < T > { /**
     * コンストラクタ
     */ public constructor ( v ? , index ? ) { this . _vector = v != undefined ? v : null ; this . _index = index != undefined ? index : 0 ; } /**
     * 代入
     */ public set ( ite ) { this . _index = ite . _index ; this . _vector = ite . _vector ; return this ; } /**
     * 前置き++演算
     */ public preIncrement ( ) { ++ this . _index ; return this ; } /**
     * 前置き--演算
     */ public preDecrement ( ) { -- this . _index ; return this ; } /**
     * 後置き++演算子
     */ public increment ( ) { const iteold = new iterator < T > ( this . _vector , this . _index ++ ) ; return iteold ; } /**
     * 後置き--演算子
     */ public decrement ( ) { const iteold = new iterator < T > ( this . _vector , this . _index -- ) ; return iteold ; } /**
     * ptr
     */ public ptr ( ) { return this . _vector . _ptr [ this . _index ] ; } /**
     * =演算子のオーバーロード
     */ public substitution ( ite ) { this . _index = ite . _index ; this . _vector = ite . _vector ; return this ; } /**
     * !=演算子のオーバーロード
     */ public notEqual ( ite ) { return this . _index != ite . _index || this . _vector != ite . _vector ; } _index : number ; _vector : csmVector < T > ; } import * as $ from './csmvector' ; export namespace Live2DCubismFramework { export const csmVector = $ . csmVector ; export type csmVector < T > = $ . csmVector < T > ; export const iterator = $ . iterator ; export type iterator < T > = $ . iterator < T > ; }