A bidirectional map consists of a two way map, that can be accessed both by the keys, or by the values. Note that in order to correctly access the elements, the types given should be comparable by identity (=== comparison). We say that a bidirectional map has keys and values, associated. The order of association is important, so for a BidirectionalMap<string, number> you can accedd by value passing numbers, but not strings, and you can access by key passing string, not numbers.

Type Parameters

  • K

  • V

Hierarchy

  • BidirectionalMap

Constructors

Properties

map: Map<K, V>
reverseMap: Map<V, K>

Methods

  • Retrieve the value associated with the given key in this bidirectional map.

    Parameters

    • key: K

      The key to retrieve the value from

    Returns V

  • Retrieve the key associated with the given value in this bidirectional map.

    Parameters

    • value: V

      The value to retrieve the key from

    Returns K

  • Return a simple map where the keys are this bidirectional map keys, and the value it's associated values.

    Returns Map<K, V>

  • Return a simple map where the keys are this bidirectional map values, and the value it's associated keys.

    Returns Map<V, K>

  • Returns true if this bidirectional map has the given key.

    Parameters

    • key: K

      The key to search

    Returns boolean

  • Returns true if this bidirectional map has the given key as value.

    Parameters

    • key: V

      The key to search

    Returns boolean

  • Set the value associated with the given key in this bidirectional map.

    Parameters

    • key: K

      The key to set the value to

    • value: V

      The value to set

    Returns void

  • Set the key associated with the given value in this bidirectional map.

    Parameters

    • value: V

      The value to set the key to

    • key: K

      The key to set

    Returns void