nikita-volkov / hashing-containers / HashingContainers.HashSet

HashSet API.


type HashSet value

Generic set of hashable elements.

Unlike Set from the "core" library it is not limited to any specific set of supported types for elements.

Construction

All construction functions require you to provide instances for Equality and Hashing explicit typeclasses.

For general introduction to explicit typeclasses, see the readme of the "typeclasses" library.

empty : Typeclasses.Classes.Equality.Equality value -> Typeclasses.Classes.Hashing.Hashing value -> HashSet value

Construct an empty HashSet, providing the required instances.

fromList : Typeclasses.Classes.Equality.Equality value -> Typeclasses.Classes.Hashing.Hashing value -> List value -> HashSet value

Construct from a list of values, providing the required instances.

fromArray : Typeclasses.Classes.Equality.Equality value -> Typeclasses.Classes.Hashing.Hashing value -> Array value -> HashSet value

Construct from an array of values, providing the required instances.

Transformation

insert : value -> HashSet value -> HashSet value

Insert a value into a set.

remove : value -> HashSet value -> HashSet value

Remove a value from a set. If the value is not found, no changes are made.

Access

member : value -> HashSet value -> Basics.Bool

Determine if a value is in a set.

isEmpty : HashSet value -> Basics.Bool

Determine if a set is empty.

size : HashSet value -> Basics.Int

O(n). Count the elements of the set. Same as foldl (\ _ x -> x + 1) 0.

foldl : (value -> folding -> folding) -> folding -> HashSet value -> folding

Fold over the values in a set.

toList : HashSet value -> List value

Convert a set into a list.