1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 17:59:10 +03:00
semantic/prototype/Doubt/BoundsCheckedArray.swift
2015-10-07 19:26:35 -04:00

17 lines
303 B
Swift

public struct BoundsCheckedArray<Element>: CollectionType {
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
}
}