1616/// This is usually an index into the `SplitArguments`.
1717/// In some cases it can be multiple indices.
1818struct InputOrigin : Equatable , ExpressibleByArrayLiteral {
19- enum Element : Comparable , Hashable {
19+ enum Element : Hashable {
2020 case argumentIndex( SplitArguments . Index )
2121 }
2222
2323 private var _elements : Set < Element > = [ ]
24- var elements : [ Element ] {
25- get {
26- Array ( _elements) . sorted ( )
27- }
28- set {
29- _elements = Set ( newValue)
30- }
31- }
3224
3325 init ( ) {
3426 }
@@ -41,20 +33,20 @@ struct InputOrigin: Equatable, ExpressibleByArrayLiteral {
4133 _elements = Set ( [ element] )
4234 }
4335
44- init ( arrayLiteral elements: InputOrigin . Element ... ) {
36+ init ( arrayLiteral elements: Element ... ) {
4537 self . init ( elements: elements)
4638 }
47-
48- static func argumentIndex ( _ index : SplitArguments . Index ) -> InputOrigin {
49- return InputOrigin ( elements : [ . argumentIndex( index ) ] )
39+
40+ init ( argumentIndex : SplitArguments . Index ) {
41+ self . init ( element : . argumentIndex( argumentIndex ) )
5042 }
5143
52- mutating func insert( _ other: InputOrigin . Element ) {
44+ mutating func insert( _ other: Element ) {
5345 guard !_elements. contains ( other) else { return }
5446 _elements. insert ( other)
5547 }
5648
57- func inserting( _ other: InputOrigin . Element ) -> InputOrigin {
49+ func inserting( _ other: Element ) -> Self {
5850 guard !_elements. contains ( other) else { return self }
5951 var result = self
6052 result. insert ( other)
@@ -64,27 +56,8 @@ struct InputOrigin: Equatable, ExpressibleByArrayLiteral {
6456 mutating func formUnion( _ other: InputOrigin ) {
6557 _elements. formUnion ( other. _elements)
6658 }
67-
68- func union( _ other: InputOrigin ) -> InputOrigin {
69- var result = self
70- result. _elements. formUnion ( other. _elements)
71- return result
72- }
73-
74- func isSubset( of other: Self ) -> Bool {
75- return _elements. isSubset ( of: other. _elements)
76- }
77-
59+
7860 func forEach( _ closure: ( Element ) -> Void ) {
7961 _elements. forEach ( closure)
8062 }
8163}
82-
83- extension InputOrigin . Element {
84- static func < ( lhs: Self , rhs: Self ) -> Bool {
85- switch ( lhs, rhs) {
86- case ( . argumentIndex( let l) , . argumentIndex( let r) ) :
87- return l < r
88- }
89- }
90- }
0 commit comments