 }
 
 public protocol MyBidirectionalCollectionType : MyForwardCollectionType {
-}
+  @warn_unused_result
+  func previous(i: Index) -> Index
+
+  func _previousInPlace(inout i: Index)
+}
+
+extension MyBidirectionalCollectionType {
+  @inline(__always)
+  public func _previousInPlace(inout i: Index) {
+    i = previous(i)
+  }
+
+  @warn_unused_result
+  public func advance(i: Index, by n: Index.Distance) -> Index {
+    if n >= 0 {
+      return _advanceForward(i, by: n)
+    }
+    var i = i
+    for var offset: Index.Distance = n; offset != 0; ++offset {
+      _previousInPlace(&i)
+    }
+    return i
+  }
+
+  @warn_unused_result
+  public func advance(i: Index, by n: Index.Distance, limit: Index) -> Index {
+    if n >= 0 {
+      return _advanceForward(i, by: n, limit: limit)
+    }
+    var i = i
+    for var offset: Index.Distance = n; offset != 0 && i != limit; ++offset {
+      _previousInPlace(&i)
+    }
+    return i
+  }
+}
+extension MyBidirectionalCollectionType
+  where Index : MyRandomAccessIndex {
+
+  @warn_unused_result
+  public func previous(i: Index) -> Index {
+    return advance(i, by: -1)
+  }
+
+  @warn_unused_result
+  public func advance(i: Index, by n: Index.Distance) -> Index {
+    return i.advancedBy(n)
+  }
+
+  @warn_unused_result
+  public func advance(i: Index, by n: Index.Distance, limit: Index) -> Index {
+    let d = i.distanceTo(limit)
+    if d == 0 || (d > 0 ? d <= n : d >= n) {
+      return limit
+    }
+    return i.advancedBy(n)
+  }
+}
+
 public protocol MyRandomAccessCollectionType : MyBidirectionalCollectionType {
-}
+  typealias Index : MyRandomAccessIndex
+}
+
 public struct DefaultUnownedForwardCollection<Collection : MyForwardCollectionType> {
   internal let _collection: Collection
 


  @warn_unused_result
  public func advance(i: Index, by n: Index.Distance) -> Index {
    return i.advancedBy(n)
  }

  @warn_unused_result
  public func advance(i: Index, by n: Index.Distance, limit: Index) -> Index {
    let d = i.distanceTo(limit)
    if d == 0 || (d > 0 ? d <= n : d >= n) {
      return limit
    }
    return i.advancedBy(n)

}

/*
public protocol MyRandomAccessIndexType : MyBidirectionalIndexType, MyStrideable,
  _RandomAccessAmbiguity {

