[Home] Module Microsoft.FSharp.Compatibility.OCaml.Hashtbl


Imperative hash tables. Shallow interface to [[Microsoft.FSharp.Collections]]. HashTable: Hash tables using the structural "hash" and "equals" functions. These tables can be used with keys of any type, but you should check that structural hashing and equality are correct for your key type. Structural hashing is efficient but not a suitable choice in all circumstances, e.g. may not hash efficiently on non-reference types and deeply-structured types. Better efficiency is typically achieved if key types are F#-generated types. These hash tables may map items to multiple keys (see find_all). The implementations are not safe for concurrent reading/writing, and so users of these tables should take an appropriate lock before reading/writing if used in a concurrent setting.

Type Definitions

TypeDescription
type CHashTable Note: an abbreviation for HashMultiMap<'key,'a>
type Provider Note: an abbreviation for Provider<'key,'a,IEqualityComparer<'key>>
type Provider A collection of operations for creating and using hash tables based on particular type-tracked hash/equality functions. Generated by the Hashtbl.Make and Hashtbl.MakeTagged functors. This type is for use when you wish to specify a comparison function once and carry around an object that is a provider of (i.e. a factory for) hashtables that utilize that comparison function. The 'tag' type parameter is used to track information about the comparison function, which helps ensure that you don't mixup maps created with different comparison functions
type t For use when not opening module, e.g. Hashtbl.t Note: an abbreviation for HashMultiMap<'key,'a>

Values

ValueDescription
val add : HashMultiMap<'key,'a> -> 'key -> 'a -> unit
Add key and data to the table.
val clear : HashMultiMap<'key,'a> -> unit
Empty the table.
val copy : HashMultiMap<'key,'a> -> HashMultiMap<'key,'a>
Create a copy of the table. Remember they are imperative and get mutated.
val create : int -> HashMultiMap<'key,'a>
Create a hash table with the suggested initial size. Inlined to enable generation of efficient hash routines for the key type in the common case.
val find : HashMultiMap<'key,'a> -> 'key -> 'a
Lookup key's data in the table. Raises exception is key not in table, if this could happen you should be using tryfind.
val find_all : HashMultiMap<'key,'a> -> 'key -> 'a list
Return all bindings for the given key
val fold : ('key -> 'a -> 'c -> 'c) -> HashMultiMap<'key,'a> -> 'c -> 'c
Fold over all bindings
val hash : 'a -> int
Hash on the structure of a value according to the F# structural hashing conventions. See Pervasives.hash
val hashq : 'a -> int
Hash on the identity of an object. See Pervasives.hashq.
val iter : ('key -> 'a -> unit) -> HashMultiMap<'key,'a> -> unit
Apply the given function to each binding in the hash table
val Make : ('key -> int) * ('key -> 'key -> bool) -> Provider<'key,'a>
Build a collection of operations for creating and using hashtables based on the given hash/equality functions. This returns a record that contains the functions you use to create and manipulate tables of this kind. The returned value is much like an ML module. You should call Make once for each new pair of key/value types. You may need to constrain the result to be an instantiation of Provider. let MyStringHashProvider : Provider<string,int> = Hashtbl.Make(myStringHash,myStringEq)
val MakeTagged :
  'tag -> Provider<'key,'a,'tag> when 'tag :> IEqualityComparer<'key>
Same as Make, except track the comparison function being used through an additional type parameter. To use this function accurately you need to define a new named class that implements IEqualityComparer and pass an instance of that class as the first argument. For example: type MyHasher = class new() = { } interface IEqualityComparer<string> with member self.GetHashCode(x) = ... member self.Equals(x,y) = ... end end let MyStringHashProvider : Hashtbl.Provider<string,int> = Hashtbl.MakeTagged(new MyStringHasher())
val mem : HashMultiMap<'key,'a> -> 'key -> bool
Test for the existence of any bindings for the given key
val of_list : ('key * 'a) list -> HashMultiMap<'key,'a>
Create a hash table using the given data
val of_seq : #seq<'key * 'a> -> HashMultiMap<'key,'a>
Create hash table using the given data Inlined to enable generation of efficient hash routines for the key type in the common case.
val remove : HashMultiMap<'key,'a> -> 'key -> unit
Remove the latest binding for the given key
val replace : HashMultiMap<'key,'a> -> 'key -> 'a -> unit
Replace the latest binding for the given key
val stats :
  string -> (out_channel -> 'key -> unit) -> out_channel ->
  HashMultiMap<'key,'a> -> unit
Print statistics on a given hash table to the given output channel
val tryfind : HashMultiMap<'key,'a> -> 'key -> 'a option
Lookup the key's data in the table

Deprecated/Unsafe Type Definitions

TypeDescription
type CHashOps

Note: This type has been renamed to Hashtbl.Provider

Note: an abbreviation for Provider<'key,'a,IEqualityComparer<'key>>
type HashTable

Note: Consider using 'Hashtbl.t<'a,'a>' or 'Collections.HashMultiMap<'key,'a>')

HashTable: Hash tables using structural "hash" and "equals" functions. Note: an abbreviation for HashMultiMap<'key,'a>

Deprecated Values

ValueDescription
[<Obsolete ("This function has been renamed. Consider using of_seq instead")>]
val of_IEnumerable : #IEnumerable<'key * 'a> -> HashMultiMap<'key,'a>

Note: This function has been renamed. Consider using of_seq instead

Create a hash table using the given data

See Also

Microsoft.FSharp.Compatibility.OCaml


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