 //    }
     
     public func remove(at i: Index) -> Iterator.Element {
-        return self.elements.remove(at: i)
+        return self.array.remove(at: i)
     }
     
     public func removeSubrange(_ subRange: Range<Index>) {
-        self.elements.removeSubrange(subRange)
+        self.array.removeSubrange(subRange)
     }
     
     public func removeAll(keepingCapacity: Bool) {
-        self.elements.removeAll(keepingCapacity: keepingCapacity)
+        self.array.removeAll(keepingCapacity: keepingCapacity)
     }
 }

    public typealias SubSequence = Array<T>.SubSequence
    
    public func makeIterator() -> Iterator {
        return self.elements.makeIterator()
    }
}

extension ArrayRef : Collection, MutableCollection {
    public subscript(bounds: Range<Int>) -> ArraySlice<T> {
        get {
            return self.elements[bounds]
        }
        set(newValue) {
            self.elements[bounds] = newValue
        }
    }

    public typealias Index = Array<T>.Index
    
    public var startIndex: Index {
        return self.elements.startIndex
    }

    public var endIndex: Index {
        return self.elements.endIndex
    }
    
    public var count: Int {
        return self.elements.count
    }
    
    public subscript(i: Index) -> T {
        get {
            return self.elements[i]
        }
        set {
            self.elements[i] = newValue
        }
    }

    public func index(after i: Int) -> Int {
        return self.elements.index(after: i)
    }
}

extension ArrayRef : RangeReplaceableCollection {
    public func reserveCapacity(n: ArrayRef.IndexDistance) {
        self.elements.reserveCapacity(n)
    }
    
    public func append(_ x: Iterator.Element) {
        self.elements.append(x)
    }
    
    public func extend<S : Sequence>(_ newElements: S) where Iterator.Element == S.Iterator.Element {
        self.elements.append(contentsOf: newElements)
    }

    public func replaceSubrange<C : Collection>(_ subRange: Range<Index>, with newElements: C) where Iterator.Element == C.Iterator.Element {
        self.elements.replaceSubrange(subRange, with: newElements)
    }
    
    public func insert(newElement: Iterator.Element, at i: Index) {
        self.elements.insert(newElement, at: i)
    }
    
//    public func insert<S: Collection>(contentsOf xs: S, at i: Index) where S.Iterator.Element == T {

// pass-by-reference.

public final class ArrayRef<T> {
    internal var array: Array<T>
    
    public init(_ array: Array<T>) {
        self.array = array
    }
    
    public convenience init() {
