     }
   }
   
+  /// Removes the element at `startIndex` and returns it.
+  ///
+  /// - Complexity: O(1).
+  /// - Requires: `self.count > 0`.
   @warn_unused_result
   public mutating func removeFirst() -> Element {
-    makeMutableAndUnique()
+    precondition(count > 0, "can't remove items from an empty collection")
+    
+    makeUniqueMutableStorage()
     return storage_.removeFirst()
   }
   
-  public mutating func removeFirst(count: Int) {
-    makeMutableAndUnique()
-    storage_.removeFirst(count)
-  }
-  
+  /// Removes the first `n` elements.
+  ///
+  /// - Complexity: O(`n`).
+  /// - Requires: `n >= 0 && self.count >= n`.
+  public mutating func removeFirst(n: Int) {
+    if n == 0 {
+      return
+    }
+    
+    precondition(n >= 0, "number of elements to remove should be non-negative")
+    precondition(count >= n,
+      "can't remove more items from a collection than it contains")
+    
+    makeUniqueMutableStorage()
+    storage_.removeFirst(n)
+  }
+  
+  /// Removes the element at the end and returns it.
+  ///
+  /// - Complexity: O(1).
+  /// - Requires: `count > 0`
   @warn_unused_result
   public mutating func removeLast() -> Element {
-    makeMutableAndUnique()
+    precondition(count > 0, "can't remove items from an empty collection")
+    
+    makeUniqueMutableStorage()
     return storage_.removeLast()
   }
   
-  public mutating func removeLast(count: Int) {
-    makeMutableAndUnique()
-    storage_.removeLast(count)
-  }
-  
+  /// Removes the last `n` elements.
+  ///
+  /// - Complexity: O(`n`).
+  /// - Requires: `n >= 0 && self.count >= n`.
+  public mutating func removeLast(n: Int) {
+    if n == 0 {
+      return
+    }
+    
+    precondition(n >= 0, "number of elements to remove should be non-negative")
+    precondition(count >= n,
+      "can't remove more items from a collection than it contains")
+    
+    makeUniqueMutableStorage()
+    storage_.removeLast(n)
+  }
+  
+  /// Removes all elements.
+  ///
+  /// Invalidates all indices with respect to `self`.
+  ///
+  /// - Parameter keepCapacity: if `true`, is a non-binding request to
+  ///   avoid releasing storage, which can be a useful optimization
+  ///   when `self` is going to be grown again.
+  ///
+  /// - Postcondition: `capacity == 0` if `keepCapacity` is `false`.
+  ///
+  /// - Complexity: O(`self.count`).
   public mutating func removeAll(keepCapacity keepCapacity: Bool = false) {
     if !isUniquelyReferencedNonObjC(&storage_) {
       let capacity = (keepCapacity) ? storage_.capacity : 0

  var storage_: Storage
}

extension CircularArray {
  public func withUnsafeBufferPointer<R>(
    @noescape body: (UnsafeBufferPointer<Element>) throws -> R
  ) rethrows -> R {
    return try storage_.withUnsafeBufferPointer(body)
  }
  
  public func withUnsafeMutableBufferPointer<R>(
    @noescape body: (UnsafeMutableBufferPointer<Element>) throws -> R
  ) rethrows -> R {
    return try storage_.withUnsafeMutableBufferPointer(body)
  }
  
  mutating func makeMutableAndUnique() {
    if !isUniquelyReferencedNonObjC(&storage_) {
      storage_ = CircularArrayBuffer(buffer: storage_)
    }
  }
}

extension CircularArray : DequeCollectionType {
  public mutating func reserveCapacity(minimumCapacity: Int) {
    makeMutableAndUnique()
    storage_.reserveCapacity(minimumCapacity)
  }
  
  public mutating func prepend(newElement: Element) {
    makeMutableAndUnique()
    storage_.prepend(newElement)
  }
  
  public mutating func prependContentsOf<
    S : SequenceType where S.Generator.Element == Element
  >(newElements: S) {

    }
  }
  
  /// Appends the elements of `newElements` to the `CircularArray`.
  ///
  /// - Complexity: O(*length of `newElements`*).
  public mutating func appendContentsOf<
    C : CollectionType where C.Generator.Element == Element
  >(newElements: C) {
