Last active
February 11, 2016 17:34
-
-
Save dabrahams/d872556291a3cb797bd5 to your computer and use it in GitHub Desktop.
SetAlgebra (and Set) naming resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/stdlib/public/core/SetAlgebra.swift b/stdlib/public/core/SetAlgebra.swift | |
index 822d5bc..9386cd5 100644 | |
--- a/stdlib/public/core/SetAlgebra.swift | |
+++ b/stdlib/public/core/SetAlgebra.swift | |
@@ -20,7 +20,7 @@ | |
/// In a model of `SetAlgebra`, some elements may subsume other | |
/// elements, where | |
/// | |
-/// > `a` **subsumes** `b` iff `([a] as Self).isSupersetOf([b])` | |
+/// > `a` **subsumes** `b` iff `([a] as Self).isSuperset(of: [b])` | |
/// | |
/// In many models of `SetAlgebra` such as `Set<Element>`, `a` | |
/// *subsumes* `b` if and only if `a == b`, but that is not always the | |
@@ -35,16 +35,16 @@ | |
/// of type `S`, and `e` is of type `S.Element`: | |
/// | |
/// - `S() == []` | |
-/// - `x.intersect(x) == x` | |
-/// - `x.intersect([]) == []` | |
-/// - `x.union(x) == x` | |
-/// - `x.union([]) == x` | |
+/// - `x.intersection(with: x) == x` | |
+/// - `x.intersection(with: []) == []` | |
+/// - `x.unioning(with: x) == x` | |
+/// - `x.unioning(with: []) == x` | |
/// - `x.contains(e)` implies `x.union(y).contains(e)` | |
-/// - `x.union(y).contains(e)` implies `x.contains(e) || y.contains(e)` | |
-/// - `x.contains(e) && y.contains(e)` iff `x.intersect(y).contains(e)` | |
-/// - `x.isSubsetOf(y)` iff `y.isSupersetOf(x)` | |
-/// - `x.isStrictSupersetOf(y)` iff `x.isSupersetOf(y) && x != y` | |
-/// - `x.isStrictSubsetOf(y)` iff `x.isSubsetOf(y) && x != y` | |
+/// - `x.unioning(with: y).contains(e)` implies `x.contains(e) || y.contains(e)` | |
+/// - `x.contains(e) && y.contains(e)` iff `x.intersection(with: y).contains(e)` | |
+/// - `x.isSubset(of: y)` iff `y.isSuperset(of: x)` | |
+/// - `x.isStrictSuperset(of: y)` iff `x.isSuperset(of: y) && x != y` | |
+/// - `x.isStrictSubset(of: y)` iff `x.isSubset(of: y) && x != y` | |
public protocol SetAlgebra : Equatable, ArrayLiteralConvertible { | |
/// A type for which `Self` provides a containment test. | |
associatedtype Element | |
@@ -63,16 +63,16 @@ public protocol SetAlgebra : Equatable, ArrayLiteralConvertible { | |
/// Returns the set of elements contained in `self`, in `other`, or in | |
/// both `self` and `other`. | |
@warn_unused_result | |
- func union(other: Self) -> Self | |
+ func unioning(with other: Self) -> Self | |
/// Returns the set of elements contained in both `self` and `other`. | |
@warn_unused_result | |
- func intersect(other: Self) -> Self | |
+ func intersection(with other: Self) -> Self | |
/// Returns the set of elements contained in `self` or in `other`, | |
/// but not in both `self` and `other`. | |
@warn_unused_result | |
- func exclusiveOr(other: Self) -> Self | |
+ func exclusiveOring(with other: Self) -> Self | |
/// If `member` is not already contained in `self`, inserts it. | |
/// | |
@@ -90,53 +90,53 @@ public protocol SetAlgebra : Equatable, ArrayLiteralConvertible { | |
/// Insert all elements of `other` into `self`. | |
/// | |
/// - Equivalent to replacing `self` with `self.union(other)`. | |
- /// - Postcondition: `self.isSupersetOf(other)` | |
- mutating func unionInPlace(other: Self) | |
+ /// - Postcondition: `self.isSuperset(of other)` | |
+ mutating func union(with other: Self) | |
/// Removes all elements of `self` that are not also present in | |
/// `other`. | |
/// | |
/// - Equivalent to replacing `self` with `self.intersect(other)` | |
- /// - Postcondition: `self.isSubsetOf(other)` | |
- mutating func intersectInPlace(other: Self) | |
+ /// - Postcondition: `self.isSubset(of other)` | |
+ mutating func intersect(with other: Self) | |
/// Replaces `self` with a set containing all elements contained in | |
/// either `self` or `other`, but not both. | |
/// | |
/// - Equivalent to replacing `self` with `self.exclusiveOr(other)` | |
- mutating func exclusiveOrInPlace(other: Self) | |
+ mutating func exclusiveOr(with other: Self) | |
//===--- Requirements with default implementations ----------------------===// | |
/// Returns the set of elements contained in `self` but not in `other`. | |
@warn_unused_result | |
- func subtract(other: Self) -> Self | |
+ func subtracting(other: Self) -> Self | |
/// Return true iff every element of `self` is contained in `other`. | |
@warn_unused_result | |
- func isSubsetOf(other: Self) -> Bool | |
+ func isSubset(of other: Self) -> Bool | |
/// Return true iff `self.intersect(other).isEmpty`. | |
@warn_unused_result | |
- func isDisjointWith(other: Self) -> Bool | |
+ func isDisjoint(with other: Self) -> Bool | |
/// Return true iff every element of `other` is contained in `self`. | |
@warn_unused_result | |
- func isSupersetOf(other: Self) -> Bool | |
+ func isSuperset(of other: Self) -> Bool | |
/// Return true iff `self.contains(e)` is `false` for all `e`. | |
var isEmpty: Bool { get } | |
/// Creates the set containing all elements of `sequence`. | |
- init<S : Sequence where S.Iterator.Element == Element>(_ sequence: S) | |
+ init<S : SequenceType where S.Generator.Element == Element>(_ sequence: S) | |
/// Removes all elements of `other` from `self`. | |
/// | |
/// - Equivalent to replacing `self` with `self.subtract(other)`. | |
- mutating func subtractInPlace(other: Self) | |
+ mutating func subtract(other: Self) | |
/// Returns `true` iff `a` subsumes `b`. | |
/// | |
- /// - Equivalent to `([a] as Self).isSupersetOf([b])` | |
+ /// - Equivalent to `([a] as Self).isSuperset(of: [b])` | |
@warn_unused_result | |
static func element(a: Element, subsumes b: Element) -> Bool | |
@@ -182,13 +182,13 @@ extension SetAlgebra { | |
/// Returns true iff every element of `self` is contained in `other`. | |
@warn_unused_result | |
- public func isSubsetOf(other: Self) -> Bool { | |
+ public func isSubset(of other: Self) -> Bool { | |
return self.intersect(other) == self | |
} | |
/// Returns true iff every element of `other` is contained in `self`. | |
@warn_unused_result | |
- public func isSupersetOf(other: Self) -> Bool { | |
+ public func isSuperset(of other: Self) -> Bool { | |
return other.isSubsetOf(self) | |
} | |
@@ -212,20 +212,20 @@ extension SetAlgebra { | |
/// Returns true iff every element of `other` is contained in `self` | |
/// and `self` contains an element that is not contained in `other`. | |
@warn_unused_result | |
- public func isStrictSupersetOf(other: Self) -> Bool { | |
+ public func isStrictSuperset(of other: Self) -> Bool { | |
return self.isSupersetOf(other) && self != other | |
} | |
/// Return true iff every element of `self` is contained in `other` | |
/// and `other` contains an element that is not contained in `self`. | |
@warn_unused_result | |
- public func isStrictSubsetOf(other: Self) -> Bool { | |
+ public func isStrictSubset(of other: Self) -> Bool { | |
return other.isStrictSupersetOf(self) | |
} | |
/// Returns `true` iff `a` subsumes `b`. | |
/// | |
- /// - Equivalent to `([a] as Self).isSupersetOf([b])` | |
+ /// - Equivalent to `([a] as Self).isSuperset(of: [b])` | |
@warn_unused_result | |
public static func element(a: Element, subsumes b: Element) -> Bool { | |
return ([a] as Self).isSupersetOf([b]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment