import * as tracing_1 from "../../../Tracing"
import * as tracing_2 from "../../../Tracing"
const fileName_1 = "(@effect-ts/system): _src/Collections/Mutable/HashSet/index.ts"
import * as I from "../../../Iterable"
import * as O from "../../../Option"
import * as MHM from "../HashMap"
export class HashSet {
  constructor() {
    this.hashMap = MHM.make()
  }

  size() {
    return this.hashMap.length.get
  }

  isEmpty() {
    return this.size() === 0
  }

  contains(a) {
    return O.getOrElse_(this.hashMap.get(a), () => false)
  }

  add(a) {
    this.hashMap.set(a, true)
    return this.contains(a)
  }

  remove(a) {
    this.hashMap.remove(a)
    return !this.contains(a)
  }

  [Symbol.iterator]() {
    return I.map_(this.hashMap, ([a]) => a)[Symbol.iterator]()
  }
}
/**
 * Creates a new set
 */

export function make() {
  return new HashSet()
}
/**
 * Calculate the number of values in a set
 */

export function size(self) {
  return self.size()
}
/**
 * returns `true` if the set is empty
 */

export function isEmpty(self) {
  return self.isEmpty()
}
/**
 * Creates a new set
 *
 * @dataFirst contains_
 */

export function contains_(self, a) {
  return self.contains(a)
}
/**
 * return true if the set contains `a`
 *
 * @dataFirst contains_
 */

export function contains(a) {
  return (self) => contains_(self, a)
}
/**
 * add `a` to the set
 */

export function add_(self, a) {
  return self.add(a)
}
/**
 * add `a` to the set
 *
 * @dataFirst add_
 */

export function add(a) {
  return (self) => add_(self, a)
}
/**
 * remove `a` from the set
 */

export function remove_(self, a) {
  return self.remove(a)
}
/**
 * remove `a` from the set
 *
 * @dataFirst remove_
 */

export function remove(a) {
  return (self) => remove_(self, a)
}
//# sourceMappingURL=index.js.map
