# Queue

#### new Cesium.Queue()
engine/Source/Core/Queue.js 7

A queue that can enqueue items at the end, and dequeue items from the front.

### Members

#### readonly length : number
engine/Source/Core/Queue.js 22

The length of the queue.

### Methods

#### clear()
engine/Source/Core/Queue.js 92

Remove all items from the queue.

#### contains(item)
engine/Source/Core/Queue.js 85

Check whether this queue contains the specified item.

Name | Type | Description
--- | --- | ---
`item` | * | The item to search for.

#### dequeue() → *
engine/Source/Core/Queue.js 44

Dequeues an item. Returns undefined if the queue is empty.

##### Returns:

The the dequeued item.

#### enqueue(item)
engine/Source/Core/Queue.js 34

Enqueues the specified item.

Name | Type | Description
--- | --- | ---
`item` | * | The item to enqueue.

#### peek() → *
engine/Source/Core/Queue.js 72

Returns the item at the front of the queue. Returns undefined if the queue is empty.

##### Returns:

The item at the front of the queue.

#### sort(compareFunction)
engine/Source/Core/Queue.js 101

Sort the items in the queue in-place.

Name | Type | Description
--- | --- | ---
`compareFunction` | Queue.Comparator | A function that defines the sort order.

### Type Definitions

#### Cesium.Queue.Comparator(a, b) → number
engine/Source/Core/Queue.js 111

A function used to compare two items while sorting a queue.

Name | Type | Description
--- | --- | ---
`a` | * | An item in the array.
`b` | * | An item in the array.

##### Returns:

Returns a negative value if `a` is less than `b`, a positive value if `a` is greater than `b`, or 0 if `a` is equal to `b`.

##### Example:

    function compareNumbers(a, b) {
        return a - b;
    }

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.