Skip to content

Commit

Permalink
[OrderedSet] Move RAC utilities to _CollectionsUtilities module
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentey committed Oct 10, 2022
1 parent 9280cf6 commit d7d7dba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

// The parts of MutableCollection that OrderedSet is able to implement.

import _CollectionsUtilities

extension OrderedSet {
/// Exchanges the values at the specified indices of the set.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@
//===----------------------------------------------------------------------===//

extension RandomAccessCollection {
@inlinable
@inline(__always)
internal func _index(at offset: Int) -> Index {
@_alwaysEmitIntoClient @inline(__always)
public func _index(at offset: Int) -> Index {
index(startIndex, offsetBy: offset)
}

@inlinable
@inline(__always)
internal func _offset(of index: Index) -> Int {
@_alwaysEmitIntoClient @inline(__always)
public func _offset(of index: Index) -> Int {
distance(from: startIndex, to: index)
}

@inlinable
@inline(__always)
internal subscript(_offset offset: Int) -> Element {
@_alwaysEmitIntoClient @inline(__always)
public subscript(_offset offset: Int) -> Element {
self[_index(at: offset)]
}
}

0 comments on commit d7d7dba

Please sign in to comment.