[Home] Module Microsoft.FSharp.Collections.Map


Immutable maps using structural comparison Maps based on structural comparison are efficient. They are not a suitable choice if keys are recursive data structures or require non-structural comparison semantics.

Type Definitions

TypeDescription
type t For use when not opening module, e.g. Map.t. Used mainly in OCaml-compatible code. Note: an abbreviation for Map<'key,'a>

Values

ValueDescription
val add : 'key -> 'a -> Map<'key,'a> -> Map<'key,'a>
Return a new map with the binding added to the given map.
[<GeneralizableValueAttribute ()>]
val empty<'key,'a> : Map<'key,'a>
The empty map
val exists : ('key -> 'a -> bool) -> Map<'key,'a> -> bool
Return true if the given predicate returns true for one of the bindings in the map.
val filter : ('key -> 'a -> bool) -> Map<'key,'a> -> Map<'key,'a>
Build a new map containing only the bindings for which the given predicate returns 'true'
val find : 'key -> Map<'key,'a> -> 'a
Lookup an element in the map, raising [[Not_found]]/[[KeyNotFoundException]] if no binding exists in the map.
val find_index : ('key -> 'a -> bool) -> Map<'key,'a> -> 'key
Evaluates the function on each mapping in the collection. Returns the key for the first mapping where the function returns 'trye'. Raise 'Not_found' if no such element exists.
val first : ('key -> 'a -> 'b option) -> Map<'key,'a> -> 'b option
Search the map looking for the first element where the given function returns a [[Some]] value
val fold : ('key -> 'a -> 'c -> 'c) -> Map<'key,'a> -> 'c -> 'c
Fold over the bindings in the map
val for_all : ('key -> 'a -> bool) -> Map<'key,'a> -> bool
Return true if the given predicate returns true for all of the bindings in the map.
val is_empty : Map<'key,'a> -> bool
Is the map empty?
val iter : ('key -> 'a -> unit) -> Map<'key,'a> -> unit
Apply the given function to each binding in the dictionary
val map : ('a -> 'b) -> Map<'key,'a> -> Map<'key,'b>
Build a new collection whose elements are the results of applying the given function to each of the elements of the collection.
val mapi : ('key -> 'a -> 'b) -> Map<'key,'a> -> Map<'key,'b>
Build a new collection whose elements are the results of applying the given function to each of the elements of the collection. The index passed to the function indicates the index of element being transformed.
val mem : 'key -> Map<'key,'a> -> bool
Test is an element is in the domain of the map
val of_array : ('key * 'a) array -> Map<'key,'a>
Return a new map made from the given bindings
val of_list : ('key * 'a) list -> Map<'key,'a>
Return a new map made from the given bindings
val of_seq : #seq<'key * 'a> -> Map<'key,'a>
Return a new map made from the given bindings
val partition :
  ('key -> 'a -> bool) -> Map<'key,'a> -> Map<'key,'a> * Map<'key,'a>
Build two new maps, one containing the bindings for which the given predicate returns 'true', and the other the remaining bindings.
val remove : 'key -> Map<'key,'a> -> Map<'key,'a>
Remove an element from the domain of the map. No exception is raised if the element is not present.
val to_array : Map<'key,'a> -> ('key * 'a) array
Returns an array of all key-value pairs in the mappinng
val to_list : Map<'key,'a> -> ('key * 'a) list
Returns a list of all key-value pairs in the mappinng
val to_seq : Map<'key,'a> -> seq<'key * 'a>
View the collection as an enumerable sequence. This collection type is also directly compatible with 'seq<KeyValuePair<_,_> >'. Note this function returns a sequence of tuples, whereas the collection itself is compatible with the logically equivalent sequence of KeyValuePairs. Using sequences of tuples tends to be more convenient in F#, however the collection itself must enumerate KeyValuePairs to conform to the .NET design guidelines and the IDictionary interface.
val tryfind : 'key -> Map<'key,'a> -> 'a option
Lookup an element in the map, returning a [[Some]] value if the element is in the domain of the map and [[None]] if not.
val tryfind_index : ('key -> 'a -> bool) -> Map<'key,'a> -> 'key option
Return the key of the first mapping in the collection that satisfies the given predicate. Return 'None' if no such element exists.

Deprecated/Unsafe Type Definitions

TypeDescription
type Map

Note: Consider using Collections.Map<_,_> or just Map<_,_>

Note: an abbreviation for Map<'key,'a>

Deprecated Values

ValueDescription
[<Obsolete ("Consider using of_seq instead")>]
val of_IEnumerable : #seq<'key * 'a> -> Map<'key,'a>

Note: Consider using of_seq instead

Return a new map made from the given bindings

See Also

Microsoft.FSharp.Collections


Documentation for assembly FSharp.Core, version 1.9.4.19, generated using F# version 1.9.4.19