@@ -39,7 +39,7 @@ public struct SortedArray<Element: Comparable> {
3939 ///
4040 /// var emptyArray = SortedArray<Int>()
4141 public init ( ) {
42- internalArray = [ ]
42+ self . internalArray = [ ]
4343 }
4444
4545 /// Creates a new SortedArray with a given sequence of elements and sorts its elements.
@@ -54,7 +54,7 @@ public struct SortedArray<Element: Comparable> {
5454
5555 @usableFromInline
5656 internal init < S: Sequence > ( sequence: S , preSorted: Bool ) where S. Iterator. Element == Element {
57- internalArray = preSorted ? Array ( sequence) : Array ( sequence) . sorted ( )
57+ self . internalArray = preSorted ? Array ( sequence) : Array ( sequence) . sorted ( )
5858 }
5959
6060 /// Returns the first index in which an element of the array satisfies the given predicate.
@@ -68,19 +68,19 @@ public struct SortedArray<Element: Comparable> {
6868 @inlinable
6969 public func firstIndex( where predicate: ( Element ) -> Bool ) -> Int ? {
7070 // cover trivial cases
71- guard !array. isEmpty else { return nil }
71+ guard !self . array. isEmpty else { return nil }
7272
73- if let first = array. first, predicate ( first) { return array. startIndex }
73+ if let first = array. first, predicate ( first) { return self . array. startIndex }
7474 if let last = array. last, !predicate( last) { return nil }
7575
7676 // binary search for first matching element
7777 var foundMatch = false
78- var lowerIndex = array. startIndex
79- var upperIndex = array. endIndex
78+ var lowerIndex = self . array. startIndex
79+ var upperIndex = self . array. endIndex
8080
8181 while lowerIndex != upperIndex {
8282 let middleIndex = lowerIndex + ( upperIndex - lowerIndex) / 2
83- guard predicate ( array [ middleIndex] ) else {
83+ guard predicate ( self . array [ middleIndex] ) else {
8484 lowerIndex = middleIndex + 1
8585 continue
8686 }
@@ -140,8 +140,8 @@ public struct SortedArray<Element: Comparable> {
140140 /// - newElement: The new element to be inserted into the array.
141141 @inlinable
142142 public mutating func insert( _ newElement: Element ) {
143- let insertIndex = internalArray. firstIndex { $0 >= newElement } ?? internalArray. endIndex
144- internalArray. insert ( newElement, at: insertIndex)
143+ let insertIndex = self . internalArray. firstIndex { $0 >= newElement } ?? self . internalArray. endIndex
144+ self . internalArray. insert ( newElement, at: insertIndex)
145145 }
146146
147147 /// Adds the contents of a sequence to the SortedArray.
@@ -152,7 +152,7 @@ public struct SortedArray<Element: Comparable> {
152152 /// - sequence
153153 @inlinable
154154 public mutating func insert< S: Sequence > ( contentsOf sequence: S ) where S. Iterator. Element == Element {
155- sequence. forEach { insert ( $0) }
155+ sequence. forEach { self . insert ( $0) }
156156 }
157157
158158 /// Removes an item from the sorted array.
@@ -163,15 +163,15 @@ public struct SortedArray<Element: Comparable> {
163163 /// - index: The index of the element to remove from the sorted array.
164164 @inlinable
165165 public mutating func remove( at index: Int ) {
166- internalArray. remove ( at: index)
166+ self . internalArray. remove ( at: index)
167167 }
168168
169169 /// Removes an item from the sorted array.
170170 ///
171171 /// - Complexity: O(*n*), where *n* is the length of the collection.
172172 @inlinable
173173 public mutating func removeAll( where condition: ( Element ) -> Bool ) {
174- internalArray. removeAll ( where: condition)
174+ self . internalArray. removeAll ( where: condition)
175175 }
176176
177177 /// Accesses a contiguous subrange of the SortedArray's elements.
@@ -180,7 +180,7 @@ public struct SortedArray<Element: Comparable> {
180180 /// - bounds: A range of the SortedArray's indices. The bounds of the range must be valid indices.
181181 @inlinable
182182 public subscript( bounds: Range < Int > ) -> SortedArray {
183- SortedArray ( sequence: array [ bounds] , preSorted: true )
183+ SortedArray ( sequence: self . array [ bounds] , preSorted: true )
184184 }
185185}
186186
@@ -194,46 +194,46 @@ extension SortedArray: BidirectionalCollection {
194194 ///
195195 /// If the collection is empty, `startIndex` is equal to `endIndex`.
196196 @inlinable public var startIndex : Int {
197- internalArray. startIndex
197+ self . internalArray. startIndex
198198 }
199199
200200 /// The collection's "past-the-end" position---that is, the position one greater than the last valid subscript argument.
201201 ///
202202 /// When you need a range that includes the last element of a collection, use the `..<` operator with `endIndex`.
203203 public var endIndex : Int {
204- internalArray. endIndex
204+ self . internalArray. endIndex
205205 }
206206
207207 /// Returns the elements of the collection in sorted order.
208208 ///
209209 /// - Returns: An array containing the sorted elements of the collection.
210210 @inlinable
211211 public func sorted( ) -> [ Element ] {
212- internalArray
212+ self . internalArray
213213 }
214214
215215 /// Returns the position immediately after the given index.
216216 ///
217217 /// - Parameter index: A valid index of the collection. `index` must be less than `endIndex`.
218218 /// - Returns: The index value immediately after `index`.
219219 public func index( after index: Int ) -> Int {
220- internalArray. index ( after: index)
220+ self . internalArray. index ( after: index)
221221 }
222222
223223 /// Returns the position immediately before the given index.
224224 ///
225225 /// - Parameter index: A valid index of the collection. `index` must be greater than `startIndex`.
226226 /// - Returns: The index value immediately before `index`.
227227 public func index( before index: Int ) -> Int {
228- internalArray. index ( before: index)
228+ self . internalArray. index ( before: index)
229229 }
230230
231231 /// Accesses the element at the specified position.
232232 ///
233233 /// - Parameter position: The position of the element to access. `position` must be a valid index of the collection.
234234 /// - Returns: The element at the specified index.
235235 public subscript( position: Int ) -> Element {
236- internalArray [ position]
236+ self . internalArray [ position]
237237 }
238238}
239239
0 commit comments