> For the complete documentation index, see [llms.txt](https://alex-myznikov.gitbook.io/adsjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alex-myznikov.gitbook.io/adsjs/api/stacks-and-queues/circulararraybuffer.md).

# CircularArrayBuffer

### new CircularArrayBuffer()

```typescript
/**
 * Creates an instance of CircularArrayBuffer.
 *
 * @param len Buffer total capacity.
 * @param elements List of elements to create the buffer with.
 * @param overwritable Flag allowing to overwrite the buffer if it is full. Is FALSE by default.
 */
constructor(len: number, elements: T[] = [], protected overwritable = false)
```

### length

```typescript
/**
 * Number of elements in the queue.
 *
 * @readonly
 */
get length(): number;
```

### maxLength

```typescript
/**
 * Maximum size of a sequence the buffer can store without overwriting itself.
 *
 * @readonly
 */
get maxLength(): number;
```

### clear()

```typescript
/**
 * Clears the queue.
 */
clear(): void;
```

### dequeue()

```typescript
/**
 * Removes the first element from the front of the queue and returns it.
 * Throws an error if the queue is empty.
 *
 * @returns Removed element.
 */
dequeue(): T;
```

### enqueue()

```typescript
/**
 * Adds element at the rear of the queue.
 *
 * @param element Element to add.
 */
enqueue(element: T): void;
```

### getFirst()

```typescript
/**
 * Gets element from the front of the queue without its removal.
 *
 * @returns Queue element.
 */
getFirst(): T;
```

### isEmpty()

```typescript
/**
 * Checks whether the queue is empty or not.
 *
 * @returns TRUE if the queue is empty, FALSE otherwise.
 */
isEmpty(): boolean;
```

### isFull()

```typescript
/**
 * Checks whether the buffer can store any more values without overwriting itself.
 *
 * @returns TRUE if the buffer is full, FALSE otherwise.
 */
isFull(): boolean;
```

### isOverwritable()

```typescript
/**
 * Checks whether the buffer can store any more values without overwriting itself.
 *
 * @returns TRUE if the buffer is full, FALSE otherwise.
 */
isFull(): boolean;
```
