FSharp.Core


Map<'Key, 'Value> Type

Immutable maps based on binary trees, where keys are ordered by F# generic comparison. By default comparison is the F# structural comparison function or uses implementations of the IComparable interface on key values.

See the Map module for further operations on maps. All members of this class are thread-safe and may be used concurrently from multiple threads.

Constructors

Constructor Description

Map(elements)

Full Usage: Map(elements)

Parameters:
    elements : seq<'Key * 'Value> - The input sequence of key/value pairs.

Returns: Map<'Key, 'Value> The resulting map.

Builds a map that contains the bindings of the given IEnumerable.

elements : seq<'Key * 'Value>

The input sequence of key/value pairs.

Returns: Map<'Key, 'Value>

The resulting map.

Instance members

Instance member Description

this.Add(key, value)

Full Usage: this.Add(key, value)

Parameters:
    key : 'Key - The key to add.
    value : 'Value - The value to add.

Returns: Map<'Key, 'Value> The resulting map.

Returns a new map with the binding added to the given map. If a binding with the given key already exists in the input map, the existing binding is replaced by the new binding in the result map.

key : 'Key

The key to add.

value : 'Value

The value to add.

Returns: Map<'Key, 'Value>

The resulting map.

this.Change(key, f)

Full Usage: this.Change(key, f)

Parameters:
    key : 'Key - The input key.
    f : 'Value option -> 'Value option - The change function.

Returns: Map<'Key, 'Value> The resulting map.

Returns a new map with the value stored under key changed according to f.

key : 'Key

The input key.

f : 'Value option -> 'Value option

The change function.

Returns: Map<'Key, 'Value>

The resulting map.

this.ContainsKey(key)

Full Usage: this.ContainsKey(key)

Parameters:
    key : 'Key - The input key.

Returns: bool True if the map contains the given key.

Tests if an element is in the domain of the map.

key : 'Key

The input key.

Returns: bool

True if the map contains the given key.

this.Count

Full Usage: this.Count

Returns: int

The number of bindings in the map.

Returns: int

this.IsEmpty

Full Usage: this.IsEmpty

Returns: bool

Returns true if there are no bindings in the map.

Returns: bool

this.[key]

Full Usage: this.[key]

Parameters:
    key : 'Key - The input key.

Returns: 'Value The value mapped to the key.

Lookup an element in the map. Raise KeyNotFoundException if no binding exists in the map.

key : 'Key

The input key.

Returns: 'Value

The value mapped to the key.

KeyNotFoundException Thrown when the key is not found.

this.Remove(key)

Full Usage: this.Remove(key)

Parameters:
    key : 'Key - The input key.

Returns: Map<'Key, 'Value> The resulting map.

Removes an element from the domain of the map. No exception is raised if the element is not present.

key : 'Key

The input key.

Returns: Map<'Key, 'Value>

The resulting map.

this.TryFind(key)

Full Usage: this.TryFind(key)

Parameters:
    key : 'Key - The input key.

Returns: 'Value option The mapped value, or None if the key is not in the map.

Lookup an element in the map, returning a Some value if the element is in the domain of the map and None if not.

key : 'Key

The input key.

Returns: 'Value option

The mapped value, or None if the key is not in the map.

this.TryGetValue(key, value)

Full Usage: this.TryGetValue(key, value)

Parameters:
    key : 'Key - The input key.
    value : byref<'Value> - A reference to the output value.

Returns: bool true if the value is present, false if not.

Lookup an element in the map, assigning to value if the element is in the domain of the map and returning false if not.

key : 'Key

The input key.

value : byref<'Value>

A reference to the output value.

Returns: bool

true if the value is present, false if not.