Skip to content

Commit d976bc4

Browse files
author
Tim Vermeulen
committed
Nest the index type
1 parent 93eabb4 commit d976bc4

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

Sources/Algorithms/Chunked.swift

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -233,37 +233,37 @@ extension EvenChunks {
233233
}
234234
}
235235

236-
public struct EvenChunksIndex<Base: Comparable>: Comparable {
237-
/// The range corresponding to the chunk at this position.
238-
@usableFromInline
239-
internal var baseRange: Range<Base>
240-
241-
/// The offset corresponding to the chunk at this position. The first chunk
242-
/// has offset `0` and all other chunks have an offset `1` greater than the
243-
/// previous.
244-
@usableFromInline
245-
internal var offset: Int
246-
247-
@inlinable
248-
internal init(_ baseRange: Range<Base>, offset: Int) {
249-
self.baseRange = baseRange
250-
self.offset = offset
251-
}
252-
253-
@inlinable
254-
public static func == (lhs: Self, rhs: Self) -> Bool {
255-
lhs.offset == rhs.offset
236+
extension EvenChunks: Collection {
237+
public struct _Index: Comparable {
238+
/// The range corresponding to the chunk at this position.
239+
@usableFromInline
240+
internal var baseRange: Range<Base.Index>
241+
242+
/// The offset corresponding to the chunk at this position. The first chunk
243+
/// has offset `0` and all other chunks have an offset `1` greater than the
244+
/// previous.
245+
@usableFromInline
246+
internal var offset: Int
247+
248+
@inlinable
249+
internal init(_ baseRange: Range<Base.Index>, offset: Int) {
250+
self.baseRange = baseRange
251+
self.offset = offset
252+
}
253+
254+
@inlinable
255+
public static func == (lhs: Self, rhs: Self) -> Bool {
256+
lhs.offset == rhs.offset
257+
}
258+
259+
@inlinable
260+
public static func < (lhs: Self, rhs: Self) -> Bool {
261+
lhs.offset < rhs.offset
262+
}
256263
}
257264

258-
@inlinable
259-
public static func < (lhs: Self, rhs: Self) -> Bool {
260-
lhs.offset < rhs.offset
261-
}
262-
}
263-
264-
extension EvenChunks: Collection {
265265
public typealias Element = Base.SubSequence
266-
public typealias Index = EvenChunksIndex<Base.Index>
266+
public typealias Index = SubSequence._Index
267267
public typealias SubSequence = EvenChunks<Base.SubSequence>
268268

269269
@inlinable
@@ -355,7 +355,7 @@ extension EvenChunks: Collection {
355355
}
356356
}
357357

358-
extension EvenChunksIndex: Hashable where Base: Hashable {}
358+
extension EvenChunks._Index: Hashable where Base.Index: Hashable {}
359359

360360
extension EvenChunks: BidirectionalCollection
361361
where Base: BidirectionalCollection

0 commit comments

Comments
 (0)