Add singleton utility

This commit is contained in:
Alexander Ignatov 2021-12-30 02:08:33 +02:00
parent d8c81e8625
commit 0b39ba8124
1 changed files with 7 additions and 1 deletions

View File

@ -174,12 +174,18 @@ public extension IterableFuzzySet where Universe: Hashable {
public extension IterableFuzzySet where S == Set<Universe> {
static func fromCrispSet(_ set: S) -> Self {
.init(set, membershipFunction: .one)
.init(set, membershipFunction: .fromCrispSet(set))
}
}
// MARK: - Utility
public extension IterableFuzzySet where Universe: Equatable, S == Array<Universe> {
static func singleton(_ u: Universe) -> Self {
.init([u], membershipFunction: .fuzzySingleton(u))
}
}
extension IterableFuzzySet.Element: Equatable where Universe: Equatable {}
extension IterableFuzzySet.Element: Hashable where Universe: Hashable {}
extension IterableFuzzySet.Element: Encodable where Universe: Encodable {}