1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 08:54:14 +03:00
semantic/prototype/Doubt/BoundsCheckedArray.swift

17 lines
303 B
Swift
Raw Normal View History

public struct BoundsCheckedArray<Element>: CollectionType {
2015-10-08 02:26:35 +03:00
public init(array: [Element]) {
self.array = array
}
let array: [Element]
public let startIndex = 0
public var endIndex: Int {
return array.count
}
public subscript (i: Int) -> Element? {
return i < count ? array[i] : nil
}
}