Table of contents
Collapse the table of content
Expand the table of content

HashIdentity.LimitedStructural<'T> Function (F#)

Den Delimarsky|Last Updated: 8/18/2017
1 Contributor

Implements a structural hash that is limited to hashing a fixed number of elements.

Namespace/Module Path: Microsoft.FSharp.Collections.HashIdentity

Assembly: FSharp.Core (in FSharp.Core.dll)


// Signature:
LimitedStructural : int -> IEqualityComparer<'T> (requires equality)

// Usage:
LimitedStructural limit


limit Type: int

The maximum number of elements to hash.

Return Value

An object that implements System.Collections.IEqualityComparer using the limited hash.


Structural hashing recursively composes a hash of a structural object by combining the hashes of each of its constituent elements. So, if you have a list composed of 20,000 elements, the hashes of each element will be composed into the hash of the list.

To save time and mitigate the risk of a stack overflow while hashing, the limited hash allows you to specify an upper bound on the number of items you would like to consider when constructing a hash over structured data. So, if you are hashing a list of 20,000 elements, you can just use its first 18 elements.

LimitedStructural uses the limitedHash function.


Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Collections.HashIdentity Module (F#)

Microsoft.FSharp.Collections Namespace (F#)

© 2020 Microsoft