peek

Summary

Returns the most earliest element pushed without removing it.

Usage

public T+ peek()

Returns

The element at the top of the queue (earliest element added) or undefined if the queue was empty.

Description

Returns the most earliest element added to the queue without removing it. If the queue is empty, undefined will be returned.

Examples

Basic Usage
1
2
3
4
5
import System;
 
auto queue = new Queue<int>([ 1, 2 ]);
Console.log(queue.peek()); // 1
Console.log(queue.peek()); // 1

Share

HTML | BBCode | Direct Link