Hyperlinkv0.8.0-beta.28

MutableHashSet

MutableHashSet.hasconsteffect/MutableHashSet.ts:307
<V>(key: V): (self: MutableHashSet<V>) => boolean
<V>(self: MutableHashSet<V>, key: V): boolean

Checks whether the MutableHashSet contains the specified value.

When to use

Use to test whether a mutable set currently contains a value.

Details

Membership follows the same hashing and equality rules as the underlying MutableHashMap.

Example (Checking for a value)

import { MutableHashSet } from "effect"

const set = MutableHashSet.make("apple", "banana", "cherry")

console.log(MutableHashSet.has(set, "apple")) // true
console.log(MutableHashSet.has(set, "grape")) // false

// Pipe-able version
const hasApple = MutableHashSet.has("apple")
console.log(hasApple(set)) // true

// Check after adding
MutableHashSet.add(set, "grape")
console.log(MutableHashSet.has(set, "grape")) // true
elementsaddremove
export const has: {
  <V>(key: V): (self: MutableHashSet<V>) => boolean
  <V>(self: MutableHashSet<V>, key: V): boolean
} = Dual.dual<
  <V>(key: V) => (self: MutableHashSet<V>) => boolean,
  <V>(self: MutableHashSet<V>, key: V) => boolean
>(2, (self, key) => MutableHashMap.has(self.keyMap, key))