[Home] Module Microsoft.FSharp.MLLib.Hashtbl


Imperative hash tables. Shallow interface to [[Microsoft.FSharp.Collections]]. This module is included mainly to make it possible to cross-compile code with other ML compilers.

Types

TypeDescription
type CHashOps A collection of operations for creating and using hash tables based on particular hash/equality functions. Generated by the Hashtbl.Make functor
type CHashTable CHashTable: Hash tables with user defined hash/equality functions. Example (for maps of strings to integers):
   let MyHash: (string,int) HashTable.CHashOps =
             HashTable.Make(MyStringHashFunction, MyStringEqualityFunction)
   ...
   let tab = MyHash.create 3 in
   MyHash.add tab "a" 3
 
Note: an abbreviation for CHashTable <'a,'b>
type Component

Deprecated: This name is deprecated. Use CHashOps instead

Note: an abbreviation for CHashOps <'a,'b>
type HashTable HashTable: Hash tables using structural "hash" and "equals" functions. Hash tables may map items to multiple keys (see find_all). 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. 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. Note: an abbreviation for HashTable <'a,'b>
type t For use when not opening module, e.g. HashTable.t Note: an abbreviation for HashTable <'a,'b>

Values

ValueDescription
val add : HashTable <'a,'b> -> 'a -> 'b -> unit
Add key and data to the table.
val clear : HashTable <'a,'b> -> unit
Empty the table.
val copy : HashTable <'a,'b> -> HashTable <'a,'b>
Create a copy of the table. Remember they are imperative and get mutated.
val create : int -> HashTable <'a,'b>
Create hash table suggesting initial size.
val find : HashTable <'a,'b> -> 'a -> 'b
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 : HashTable <'a,'b> -> 'a -> 'b list
Return all bindings for the given key
val fold : ('a -> 'b -> 'c -> 'c) -> HashTable <'a,'b> -> '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 : ('a -> 'b -> unit) -> HashTable <'a,'b> -> unit
Apply the given function to each binding in the hash table
val Make : ('a -> int) * ('a -> 'a -> bool) -> CHashOps <'a,'b>
A functor to build a collection of operations for creating and using hashtables based on the given hash/equality functions Use Make to specify a new kind of CHashTables. 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, except it is a record in the core language.) 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 CHashOps.
val mem : HashTable <'a,'b> -> 'a -> bool
Test for the existence of any bindings for the given key
val remove : HashTable <'a,'b> -> 'a -> unit
Remove the latest binding for the given key
val replace : HashTable <'a,'b> -> 'a -> 'b -> unit
Replace the latest binding for the given key
val stats :
  string -> (out_channel -> 'a -> unit) -> out_channel -> HashTable <'a,'b> ->
  unit
Print statistics on a given hash table to the given output channel
val tryfind : HashTable <'a,'b> -> 'a -> 'b option
Lookup the key's data in the table

See Also

Microsoft.FSharp.MLLib


Documentation for assembly mllib, version 1.1.10.1, generated using F# version 1.1.10.1