# Class Queue<T>

A simple bounded FIFO queue with optional eviction notifications.

#### Type Parameters

- T

- Defined in src/router/common/queue.js:7

##### Index

### Constructors

constructor

### Properties

_evictListeners
_items
_limit
onEvict

### Methods

clear
dequeue
enqueue
evict
peekHead
peekTail
remove
size

## Constructors

### constructor

- new Queue<T>(items?: T[], limit?: number): Queue<T>

  #### Type Parameters

  - T

  #### Parameters

  - `Optional` items: T[] = []

    Initial queue items.

  - `Optional` limit: number = null

    Maximum allowed items before eviction (null = unlimited).

  #### Returns Queue<T>

  - Defined in src/router/common/queue.js:12

## Properties

### _evictListeners

_evictListeners: ((item: T) => void)[]

- Defined in src/router/common/queue.js:20

### _items

_items: T[]

- Defined in src/router/common/queue.js:14

### _limit

_limit: number

- Defined in src/router/common/queue.js:17

### onEvict

onEvict: (listener: (item: T) => void) => void

Register a listener that will be called with the evicted item.

- Defined in src/router/common/queue.js:26

## Methods

### clear

- clear(): T[]

  Clears all items from the queue.

  #### Returns T[]

  The previously stored items.

  - Defined in src/router/common/queue.js:66

### dequeue

- dequeue(): T

  Removes and returns the first item in the queue.

  #### Returns T

  - Defined in src/router/common/queue.js:58

### enqueue

- enqueue(item: T): T

  Adds an item to the end of the queue, evicting the head if over limit.

  #### Parameters

  - item: T

  #### Returns T

  - Defined in src/router/common/queue.js:34

### evict

- evict(): T

  Removes the head item and notifies eviction listeners.

  #### Returns T

  - Defined in src/router/common/queue.js:46

### peekHead

- peekHead(): T

  Returns the item at the head (first).

  #### Returns T

  - Defined in src/router/common/queue.js:102

### peekTail

- peekTail(): T

  Returns the item at the tail (last).

  #### Returns T

  - Defined in src/router/common/queue.js:94

### remove

- remove(item: T): false | T

  Removes a specific item from the queue.

  #### Parameters

  - item: T

  #### Returns false | T

  The removed item, or false if not found.

  - Defined in src/router/common/queue.js:85

### size

- size(): number

  Returns the current number of items.

  #### Returns number

  - Defined in src/router/common/queue.js:76