MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeCompareSet

Function makeCompareSet

packages/effect/src/Equal.ts:387–408  ·  view source on GitHub ↗
(equivalence: Equivalence<A>)

Source from the content-addressed store, hash-verified

385
386/** @internal */
387export function makeCompareSet<A>(equivalence: Equivalence<A>) {
388 return function compareSets(self: Iterable<A>, that: Iterable<A>): boolean {
389 const thatValues = Array.from(that)
390 for (const selfValue of self) {
391 let found = false
392 for (let i = 0; i < thatValues.length; i++) {
393 const thatValue = thatValues[i]
394 if (equivalence(selfValue, thatValue)) {
395 thatValues[i] = thatValues[thatValues.length - 1]
396 thatValues.pop()
397 found = true
398 break
399 }
400 }
401 if (!found) {
402 return false
403 }
404 }
405
406 return true
407 }
408}
409
410const compareSets = makeCompareSet(compareBoth)
411

Callers 1

Equal.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected