 
 NewCollection.test("popFirst") {
   let c = MyArray([1,2,3])
-  var s0 = c[c.indices]
+  var s0 = c[c.startIndex..<*c.endIndex]
   var s = c[MyRange(start: c.startIndex, end: c.endIndex)]
   expectOptionalEqual(1, s.popFirst())
   expectOptionalEqual(2, s.popFirst())

  public subscript(i: Index) -> Index {
    return i
  }
}

// FIXME: in order for all this to be usable, we need to unify MyRange and

  }
}
*/

//------------------------------------------------------------------------
// Bubble sort

extension MyMutableCollectionType
  where
  IndexRange.Generator.Element == Index,
  IndexRange.Index == Index
{
  public mutating func bubbleSortInPlace(
    @noescape isOrderedBefore: (Generator.Element, Generator.Element) -> Bool
  ) {
    if isEmpty { return }
    if next(startIndex) == endIndex { return }

    while true {
      var swapped = false
      for i in OldSequence(indices) {
        if i == endIndex { break }
        let ni = next(i)
        if ni == endIndex { break }
        if isOrderedBefore(self[ni], self[i]) {
          swap(&self[i], &self[ni])
          swapped = true
        }
      }
      if !swapped {
        break
      }
    }
  }
}

extension MyMutableCollectionType
  where
  Generator.Element : Comparable,
  IndexRange.Generator.Element == Index,
  IndexRange.Index == Index
{
  public mutating func bubbleSortInPlace() {
    bubbleSortInPlace { $0 < $1 }
  }
}

//------------------------------------------------------------------------
// Bubble sort

extension MyRandomAccessCollectionType
  where
  IndexRange.Generator.Element == Index,
  IndexRange.Index == Index
{
  public func lowerBoundOf(
    element: Generator.Element,
    @noescape isOrderedBefore: (Generator.Element, Generator.Element) -> Bool
  ) -> Index {
    var low = startIndex
    var subrangeCount = count
    while subrangeCount != 0 {
      let midOffset = subrangeCount / 2
      let mid = advance(low, by: midOffset)
      if isOrderedBefore(self[mid], element) {
        low = next(mid)
        subrangeCount -= midOffset + 1
      } else {
        subrangeCount = midOffset
      }
    }
    return low
  }
}

extension MyRandomAccessCollectionType
  where
  Generator.Element : Comparable,
  IndexRange.Generator.Element == Index,
  IndexRange.Index == Index
{
  public func lowerBoundOf(element: Generator.Element) -> Index {
    return lowerBoundOf(element) { $0 < $1 }
  }
}

//------------

public protocol MyStrideable : Comparable {
