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

  • UniqueTreeMap<Key, T, TreeMap<Key, T>, TreeMap.Iterator<Key, T>, TreeMap.ReverseIterator<Key, T>>
    • TreeMap

Implements

Index

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

  • begin(): TreeMap.Iterator<Key, T>

clear

  • clear(): void

count

  • count(key: Key): number

emplace

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

emplace_hint

  • emplace_hint(hint: TreeMap.Iterator<Key, T>, key: Key, val: T): TreeMap.Iterator<Key, T>

empty

  • empty(): boolean

end

  • end(): TreeMap.Iterator<Key, T>

equal_range

  • equal_range(key: Key): Pair<TreeMap.Iterator<Key, T>, TreeMap.Iterator<Key, T>>

erase

  • erase(key: Key): number
  • erase(it: TreeMap.Iterator<Key, T>): TreeMap.Iterator<Key, T>
  • erase(begin: TreeMap.Iterator<Key, T>, end: TreeMap.Iterator<Key, T>): TreeMap.Iterator<Key, T>

extract

  • extract(key: Key): Entry<Key, T>
  • extract(pos: TreeMap.Iterator<Key, T>): TreeMap.Iterator<Key, T>

find

  • find(key: Key): TreeMap.Iterator<Key, T>

get

  • get(key: Key): T

has

  • has(key: Key): boolean

insert

  • insert(pair: IPair<Key, T>): Pair<TreeMap.Iterator<Key, T>, boolean>
  • insert(hint: TreeMap.Iterator<Key, T>, pair: IPair<Key, T>): TreeMap.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<TreeMap.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: TreeMap.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 TreeMap.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<TreeMap.Iterator<Key, T>, boolean>
  • insert_or_assign(hint: TreeMap.Iterator<Key, T>, key: Key, value: T): TreeMap.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<TreeMap.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: TreeMap.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 TreeMap.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): TreeMap.Iterator<Key, T>

merge

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

push

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

rbegin

  • rbegin(): TreeMap.ReverseIterator<Key, T>

rend

  • rend(): TreeMap.ReverseIterator<Key, T>

set

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

size

  • size(): number

swap

toJSON

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

upper_bound

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

value_comp

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

Generated using TypeDoc