             switch ordering {
             case .Min:
                 if items[right] < items[index] {
-                    return Heap(items: self.swapItemsForIndices(right, index), ordering: ordering).downHeap(right)
+                    return Heap(items: items.swapValuesForIndices(right, index), ordering: ordering).downHeap(right)
                 } else {
                     return self
                 }
             case .Max:
                 if items[right] > items[index] {
-                    return Heap(items: self.swapItemsForIndices(right, index), ordering: ordering).downHeap(right)
+                    return Heap(items: items.swapValuesForIndices(right, index), ordering: ordering).downHeap(right)
                 } else {
                     return self
                 }

    }
    
    private func downHeap(index: Int) -> Heap {
        let (leftChildIndex, rightChildIndex) = self.childIndicesForIndex(index)
        
        switch (leftChildIndex, rightChildIndex) {
        case (.None, .None):
            return self
        case (.Some(let left), .None):
            switch ordering {
            case .Min:
                if items[left] < items[index] {
                    return Heap(items: self.swapItemsForIndices(left, index), ordering: ordering).downHeap(left)
                } else {
                    return self
                }
            case .Max:
                if items[left] > items[index] {
                    return Heap(items: self.swapItemsForIndices(left, index), ordering: ordering).downHeap(left)
                } else {
                    return self
                }

    
    // Delete the root from the heap, return the new heap
    func extract() -> Heap {
        let newHeap = Heap(items: items.moveLastElementToFront(), ordering: ordering)
        return newHeap.downHeap(0)
    }
}

// Implicit heap data strcuture can be navigated with index arithmentic
extension Heap {
    
    private func parentIndexForIndex(index: Int) -> Int? {
        guard index > 0 else {
            return nil
        }
        return (index - 1) / 2
    }
    
    private func rightChildIndexForIndex(index: Int) -> Int? {
        let rightChildIndex = 2 * index + 2
        return (rightChildIndex < items.endIndex) ? rightChildIndex : nil
    }
    
    private func leftChildIndexForIndex(index: Int) -> Int? {
        let leftChildIndex = 2 * index + 1
        return (leftChildIndex < items.endIndex) ? leftChildIndex : nil
    }
}

// Restore heap invariants
extension Heap {
    
    private func upHeap(index: Int) -> Heap {
