interface BiMap<K,V>
A type-invariant immutable bi-directional Map where keys and values have a one-to-one mapping. See the BiMap documentation and the BiMap API documentation
Companion namespace: BiMap
Extends: FastIterable<T>
Implemented by: BiMapEmpty<K,V>
, BiMap.NonEmpty<K,V>
Type parameters
Name | Description |
---|---|
K | the key type |
V | the value type |
const b1 = BiMap.empty<number, string>()
const b2 = BiMap.of([1, 'a'], [2, 'b'])
Properties
context
Returns the context
associated to this collection instance.
context
context
associated to this collection instance.isEmpty
Returns true if the collection is empty.
isEmpty
keyValueMap
Returns the Map representation of the key to value mapping.
keyValueMap
size
Returns the number of entries
size
valueKeyMap
Returns the Map representation of the key to value mapping.
valueKeyMap
Methods
[Symbol.iterator]
Returns a FastIterator
instance used to iterate over the values of this Iterable
.
[Symbol.iterator]
FastIterator
instance used to iterate over the values of this Iterable
.addEntries
Returns the collection with the entries from the given StreamSource
entries
added.
addEntries
StreamSource
entries
added.addEntry
Returns the collection with given entry
added.
addEntry
entry
added.assumeNonEmpty
Returns the collection as a .NonEmpty type
assumeNonEmpty
filter
Returns a collection containing only those entries that satisfy given pred
predicate.
filter
pred
predicate.forEach
Performs given function f
for each entry of the collection, using given state
as initial traversal state.
forEach
f
for each entry of the collection, using given state
as initial traversal state.getKey
Returns the key associated with the given value
, or given otherwise
value if the key is not in the collection.
getKey
value
, or given otherwise
value if the key is not in the collection.getValue
Returns the value associated with the given key
, or given otherwise
value if the key is not in the collection.
getValue
key
, or given otherwise
value if the key is not in the collection.hasKey
Returns true if the given key
is present in the collection.
hasKey
key
is present in the collection.hasValue
Returns true if the given value
is present in the collection.
hasValue
value
is present in the collection.nonEmpty
Returns true if there is at least one entry in the collection, and instructs the compiler to treat the collection as a .NonEmpty type.
nonEmpty
removeKey
Returns the collection where the entry associated with given key
is removed if it was part of the collection.
removeKey
key
is removed if it was part of the collection.removeKeyAndGet
Returns a tuple containing the collection of which the entry associated with given key
is removed, and the value that is associated with that key. If the key is not present, it will return undefined instead.
removeKeyAndGet
key
is removed, and the value that is associated with that key. If the key is not present, it will return undefined instead.removeKeys
Returns the collection where the entries associated with each key in given keys
are removed if they were present.
removeKeys
keys
are removed if they were present.removeValue
Returns the collection where the entry associated with given value
is removed if it was part of the collection.
removeValue
value
is removed if it was part of the collection.removeValueAndGet
Returns a tuple containing the collection of which the entry associated with given value
is removed, and the key that is associated with that value. If the value is not present, it will return undefined instead.
removeValueAndGet
value
is removed, and the key that is associated with that value. If the value is not present, it will return undefined instead.removeValues
Returns the collection where the entries associated with each value in given values
are removed if they were present.
removeValues
values
are removed if they were present.set
Returns the collection with the given key
associated to the given value
.
set
key
associated to the given value
.stream
Returns a Stream
containing all entries of this collection as tuples of key and value.
stream
Stream
containing all entries of this collection as tuples of key and value.streamKeys
Returns a Stream
containing all keys of this collection.
streamKeys
Stream
containing all keys of this collection.streamValues
Returns a Stream
containing all values of this collection.
streamValues
Stream
containing all values of this collection.toArray
Returns an array containing all entries in this collection.
toArray
toBuilder
Returns a builder object containing the entries of this collection.
toBuilder
toJSON
Returns a JSON representation of this collection.
toJSON
toString
Returns a string representation of this collection.
toString
updateKeyAtValue
Returns the collection where the key associated with given value
is updated with the given keyUpdate
value or update function.
updateKeyAtValue
value
is updated with the given keyUpdate
value or update function.updateValueAtKey
Returns the collection where the value associated with given key
is updated with the given valueUpdate
value or update function.
updateValueAtKey
key
is updated with the given valueUpdate
value or update function.