"use strict"
var __createBinding =
  (this && this.__createBinding) ||
  (Object.create
    ? function (o, m, k, k2) {
        if (k2 === undefined) k2 = k
        Object.defineProperty(o, k2, {
          enumerable: true,
          get: function () {
            return m[k]
          }
        })
      }
    : function (o, m, k, k2) {
        if (k2 === undefined) k2 = k
        o[k2] = m[k]
      })
var __setModuleDefault =
  (this && this.__setModuleDefault) ||
  (Object.create
    ? function (o, v) {
        Object.defineProperty(o, "default", { enumerable: true, value: v })
      }
    : function (o, v) {
        o["default"] = v
      })
var __importStar =
  (this && this.__importStar) ||
  function (mod) {
    if (mod && mod.__esModule) return mod
    var result = {}
    if (mod != null)
      for (var k in mod)
        if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
          __createBinding(result, mod, k)
    __setModuleDefault(result, mod)
    return result
  }
Object.defineProperty(exports, "__esModule", { value: true })
exports.remove =
  exports.remove_ =
  exports.add =
  exports.add_ =
  exports.contains =
  exports.contains_ =
  exports.isEmpty =
  exports.size =
  exports.make =
  exports.HashSet =
    void 0
const tracing_1 = __importStar(require("../../../Tracing"))
const fileName_1 = "(@effect-ts/system): _src/Collections/Mutable/HashSet/index.ts"
const I = __importStar(require("../../../Iterable"))
const O = __importStar(require("../../../Option"))
const MHM = __importStar(require("../HashMap"))
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]()
  }
}
exports.HashSet = HashSet
/**
 * Creates a new set
 */
function make() {
  return new HashSet()
}
exports.make = make
/**
 * Calculate the number of values in a set
 */
function size(self) {
  return self.size()
}
exports.size = size
/**
 * returns `true` if the set is empty
 */
function isEmpty(self) {
  return self.isEmpty()
}
exports.isEmpty = isEmpty
/**
 * Creates a new set
 *
 * @dataFirst contains_
 */
function contains_(self, a) {
  return self.contains(a)
}
exports.contains_ = contains_
/**
 * return true if the set contains `a`
 *
 * @dataFirst contains_
 */
function contains(a) {
  return (self) => contains_(self, a)
}
exports.contains = contains
/**
 * add `a` to the set
 */
function add_(self, a) {
  return self.add(a)
}
exports.add_ = add_
/**
 * add `a` to the set
 *
 * @dataFirst add_
 */
function add(a) {
  return (self) => add_(self, a)
}
exports.add = add
/**
 * remove `a` from the set
 */
function remove_(self, a) {
  return self.remove(a)
}
exports.remove_ = remove_
/**
 * remove `a` from the set
 *
 * @dataFirst remove_
 */
function remove(a) {
  return (self) => remove_(self, a)
}
exports.remove = remove
//# sourceMappingURL=index.js.map
