     }
     
     public var startIndex: Index {
-        // TODO: We should cache this result
-        
         // If this winds up being NSNotFound, that's ok because then endIndex is also NSNotFound, and empty collections have startIndex == endIndex
-        return Index(firstIn: self)
+        let extent = _range(at: 0)
+        return Index(value: extent.lowerBound, extent: extent, rangeIndex: 0, rangeCount: _rangeCount)
     }
 
     public var endIndex: Index {
-        // TODO: We should cache this result
-        
-        return Index(lastIn: self)
+        let rangeCount = _rangeCount
+        let rangeIndex = rangeCount - 1
+        let extent : Range<Int>
+        let value : Int
+        if rangeCount > 0 {
+            extent = _range(at: rangeCount - 1)
+            value = extent.upperBound // "1 past the end" position is the last range, 1 + the end of that range's extent
+        } else {
+            extent = 0..<0
+            value = 0
+        }
+        
+        return Index(value: value, extent: extent, rangeIndex: rangeIndex, rangeCount: rangeCount)
     }
     
     public subscript(index : Index) -> Element {

    /// - parameter range: The range of integers to include.
    public func indexRange(in range: Range<Element>) -> Range<Index> {
        if range.isEmpty {
            let i = Index(indexSet: self, index: 0)
            return i..<i
        }
        
        if range.lowerBound > last || (range.upperBound - 1) < first {
            let i = Index(indexSet: self, index: 0)
            return i..<i
        }
        
        let resultFirst = Index(indexSet: self, index: integerGreaterThanOrEqualTo(range.lowerBound))
        let resultLast = Index(indexSet: self, index: integerLessThanOrEqualTo(range.upperBound - 1))
        return resultFirst..<resultLast.successor()
    }
    
    /// Return a `Range<IndexSet.Index>` which can be used to subscript the index set.

        
    }
    
    /// The mechanism for accessing the integers stored in an IndexSet.
    public struct Index : CustomStringConvertible, Comparable {
        private var value : IndexSet.Element
        private var extent : Range<IndexSet.Element>
        private var rangeIndex : Int
        private let rangeCount : Int
        
        private init(value: Int, extent: Range<Int>, rangeIndex: Int, rangeCount: Int) {
            self.value = value
            self.extent = extent
            self.rangeCount = rangeCount
            self.rangeIndex = rangeIndex
        }
        
        public var description: String {
            return "index \(value) in a range of \(extent) [range #\(rangeIndex + 1)/\(rangeCount)]"
        }
    }

