Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TreeMap<Key, T>

Unique-key Map based on Tree.

author

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

Type parameters

  • Key

  • T

Hierarchy

Implements

Index

Type aliases

Static Iterator

Iterator<Key, T>: Iterator<Key, T, true, TreeMap<Key, T>>

Iterator of TreeMap

Type parameters

  • Key

  • T

Static ReverseIterator

ReverseIterator<Key, T>: ReverseIterator<Key, T, true, TreeMap<Key, T>>

Reverse iterator of TreeMap

Type parameters

  • Key

  • T

Constructors

constructor

  • Default Constructor.

    Parameters

    • Optional comp: Comparator<Key>

      A binary function predicates x element would be placed before y. When returns true, then x precedes y. Note that, because equality is predicated by !comp(x, y) && !comp(y, x), the function must not cover the equality like <= or >=. It must exclude the equality like < or >. Default is less.

    Returns TreeMap

  • Initializer Constructor.

    Parameters

    • items: IPair<Key, T>[]

      Items to assign.

    • Optional comp: Comparator<Key>

      A binary function predicates x element would be placed before y. When returns true, then x precedes y. Note that, because equality is predicated by !comp(x, y) && !comp(y, x), the function must not cover the equality like <= or >=. It must exclude the equality like < or >. Default is less.

    Returns TreeMap

  • Copy Constructor.

    Parameters

    • obj: TreeMap<Key, T>

      Object to copy.

    Returns TreeMap

  • Range Constructor.

    Parameters

    • first: Readonly<IForwardIterator<IPair<Key, T>>>

      Input iterator of the first position.

    • last: Readonly<IForwardIterator<IPair<Key, T>>>

      Input iterator of the last position.

    • Optional comp: Comparator<Key>

      A binary function predicates x element would be placed before y. When returns true, then x precedes y. Note that, because equality is predicated by !comp(x, y) && !comp(y, x), the function must not cover the equality like <= or >=. It must exclude the equality like < or >. Default is less.

    Returns TreeMap

Methods

[Symbol.iterator]

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

assign

  • assign<InputIterator>(first: InputIterator, last: InputIterator): void

begin

clear

  • clear(): void

count

  • count(key: Key): number

emplace

  • emplace(key: Key, val: T): Pair<Iterator<Key, T>, boolean>

emplace_hint

empty

  • empty(): boolean

end

equal_range

erase

extract

find

get

  • get(key: Key): T

has

  • has(key: Key): boolean

insert

  • insert(pair: IPair<Key, T>): Pair<Iterator<Key, T>, boolean>
  • insert(hint: Iterator<Key, T>, pair: IPair<Key, T>): Iterator<Key, T>
  • insert<InputIterator>(first: InputIterator, last: InputIterator): void
  • Insert an element.

    Parameters

    • pair: IPair<Key, T>

      A tuple to be referenced for the insert.

    Returns Pair<Iterator<Key, T>, boolean>

    Pair of an iterator to the newly inserted element and true, if the specified key doesn't exist, otherwise Pair of iterator to the ordinary element and false.

  • Insert an element with hint.

    Parameters

    • hint: Iterator<Key, T>

      Hint for the position where the element can be inserted.

    • pair: IPair<Key, T>

      A tuple to be referenced for the insert.

    Returns Iterator<Key, T>

    An iterator to the newly inserted element, if the specified key doesn't exist, otherwise an iterator to the ordinary element.

  • Insert range elements.

    Type parameters

    Parameters

    • first: InputIterator

      Input iterator of the first position.

    • last: InputIterator

      Input iteartor of the last position.

    Returns void

insert_or_assign

  • insert_or_assign(key: Key, value: T): Pair<Iterator<Key, T>, boolean>
  • insert_or_assign(hint: Iterator<Key, T>, key: Key, value: T): Iterator<Key, T>
  • Insert or assign an element.

    Parameters

    • key: Key

      Key to be mapped or search for.

    • value: T

      Value to insert or assign.

    Returns Pair<Iterator<Key, T>, boolean>

    Pair of an iterator to the newly inserted element and true, if the specified key doesn't exist, otherwise Pair of iterator to the ordinary element and false.

  • Insert or assign an element with hint.

    Parameters

    • hint: Iterator<Key, T>

      Hint for the position where the element can be inserted.

    • key: Key

      Key to be mapped or search for.

    • value: T

      Value to insert or assign.

    Returns Iterator<Key, T>

    An iterator to the newly inserted element, if the specified key doesn't exist, otherwise an iterator to the ordinary element.

key_comp

  • key_comp(): Comparator<Key>

lower_bound

  • lower_bound(key: Key): Iterator<Key, T>

merge

  • merge(source: TreeMap<Key, T>): void

push

  • push(...items: IPair<Key, T>[]): number

rbegin

rend

set

  • set(key: Key, val: T): void

size

  • size(): number

swap

toJSON

  • toJSON(): Array<Entry<Key, T>>

upper_bound

  • upper_bound(key: Key): Iterator<Key, T>

value_comp

  • value_comp(): Comparator<IPair<Key, T>>

Generated using TypeDoc