+ return this.length;
+ }
+
+ public concat(...items: (T | ConcatArray<T>)[]): CircularArray<T> {
+ const concatenatedCircularArray = super.concat(items as T[]) as CircularArray<T>;
+ concatenatedCircularArray.size = this.size;
+ if (concatenatedCircularArray.length > concatenatedCircularArray.size) {
+ concatenatedCircularArray.splice(
+ 0,
+ concatenatedCircularArray.length - concatenatedCircularArray.size
+ );
+ }
+ return concatenatedCircularArray;
+ }
+
+ public splice(start: number, deleteCount?: number, ...items: T[]): T[] {
+ let itemsRemoved: T[];
+ if (arguments.length >= 3 && typeof deleteCount !== 'undefined') {
+ itemsRemoved = super.splice(start, deleteCount);
+ // FIXME: that makes the items insert not in place
+ this.push(...items);
+ } else if (arguments.length === 2) {
+ itemsRemoved = super.splice(start, deleteCount);
+ } else {
+ itemsRemoved = super.splice(start);
+ }
+ return itemsRemoved;
+ }
+
+ public resize(size: number): void {
+ this.checkSize(size);
+ if (size === 0) {
+ this.length = 0;
+ } else if (size < this.size) {
+ for (let i = size; i < this.size; i++) {
+ super.pop();
+ }
+ }
+ this.size = size;
+ }
+
+ public empty(): boolean {
+ return this.length === 0;
+ }
+
+ public full(): boolean {
+ return this.length === this.size;