license import { RingBuffer } from './ring_buffer' ; export class GrowingRingBuffer < T > extends RingBuffer < T > { private static INITIAL_CAPACITY = 32 ; /**
     * Constructs a `GrowingRingBuffer`.
     */ constructor ( ) { super ( GrowingRingBuffer . INITIAL_CAPACITY ) ; } isFull ( ) { return false ; } push ( value ) { if ( super . isFull ( ) ) { this . expand ( ) ; } super . push ( value ) ; } unshift ( value ) { if ( super . isFull ( ) ) { this . expand ( ) ; } super . unshift ( value ) ; } /**
     * Doubles the capacity of the buffer.
     */ private expand ( ) { const newCapacity = this . capacity * 2 ; const newData = new Array < T > ( newCapacity ) ; const len = this . length ( ) ; for ( let i = 0 ; i < len ; i ++ ) { newData [ i ] = this . get ( this . wrap ( this . begin + i ) ) ; } this . data = newData ; this . capacity = newCapacity ; this . doubledCapacity = 2 * this . capacity ; this . begin = 0 ; this . end = len ; } }