Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Deque<T>

Double ended queue.

author

Jeongho Nam - https://github.com/samchon

Type parameters

  • T

Hierarchy

Implements

  • IContainer<T, Deque<T>, Deque.Iterator<T>, Deque.ReverseIterator<T>, T>
  • ILinearContainerBase<T, Deque<T>, Deque.Iterator<T>, Deque.ReverseIterator<T>, T>
  • IArrayContainer<T, Deque<T>, Deque.Iterator<T>, Deque.ReverseIterator<T>>

Index

Constructors

constructor

Properties

Private capacity_

capacity_: number

Maximum capacity that current matrix_ can store in.

Private matrix_

matrix_: Array<Array<T>>

A matrix containing elements.

This matrix_ is the biggest difference one between Vector and Deque. Its number of rows follows {@link ROW_SIZE} and number of columns follows {@link get_col_size} which returns divide of capacity and {@link ROW_SIZE}.

By separating segment of elements (segment: row, elements in a segment: col), Deque takes advantage of time complexity on inserting element in middle position. Deque is {@link ROW_SIZE} times faster than Vector when inserting elements in middle position.

However, separating segment of elements from matrix, Deque also takes disadvantage of time complexity on accessing element. Deque is {@link ROW_SIZE} times slower than Vector when accessing element.

Private size_

size_: number

Number of elements stored in the Deque

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<T>

Protected _Pop_back

  • _Pop_back(): void

assign

  • assign(n: number, val: T): void
  • assign<InputIterator>(first: InputIterator, last: InputIterator): void

at

  • at(index: number): T

back

  • back(): T
  • back(val: T): void

begin

  • begin(): Deque.Iterator<T>

capacity

  • capacity(): number

clear

  • clear(): void

empty

  • empty(): boolean

end

  • end(): Deque.Iterator<T>

erase

  • erase(it: Deque.Iterator<T>): Deque.Iterator<T>
  • erase(first: Deque.Iterator<T>, last: Deque.Iterator<T>): Deque.Iterator<T>

front

  • front(): T
  • front(val: T): void

insert

  • insert(pos: Deque.Iterator<T>, val: T): Deque.Iterator<T>
  • insert(pos: Deque.Iterator<T>, n: number, val: T): Deque.Iterator<T>
  • insert<InputIterator>(pos: Deque.Iterator<T>, first: InputIterator, last: InputIterator): Deque.Iterator<T>

nth

  • nth(index: number): Deque.Iterator<T>

pop_back

  • pop_back(): void

pop_front

  • pop_front(): void

push

  • push(...items: T[]): number

push_back

  • push_back(val: T): void

push_front

  • push_front(val: T): void

rbegin

  • rbegin(): Deque.ReverseIterator<T>

rend

  • rend(): Deque.ReverseIterator<T>

reserve

  • reserve(n: number): void

resize

  • resize(n: number): void

set

  • set(index: number, val: T): void

shrink_to_fit

  • shrink_to_fit(): void

size

  • size(): number

swap

  • swap(obj: Deque<T>): void

toJSON

  • toJSON(): Array<T>

Generated using TypeDoc