import ArrayIterable from '../iteration/iterable-array';
import extend from '../utils/extend';
import buffer from '../utils/buffer';
import bufferTo from '../utils/buffer-to';
import isArrayLike from'../utils/is-array-like';

/**
* Initializes a new instance of the abstract Collection class.
*/
export default function Collection(value) {
    if (value !== null && value !== undefined) {
        value = isArrayLike(value) ? value : buffer(value);
    }

    ArrayIterable.call(this, value);
}

extend(Collection, ArrayIterable, {
    /**
    * Gets the number of elements contained in the Collection.
    * @returns {Number}
    */
    count: function () {
        return this.toArray().length;
    },

    /**
    * Copies the Collection to an existing one-dimensional Array, starting at the specified array index.
    * @param {Array} array The one-dimensional Array that is the destination of the elements copied from Collection.
    * @param {Number} arrayIndex The zero-based index in array at which copying begins.
    */
    copyTo: function (array, arrayIndex) {
        bufferTo(this.toArray(), array, arrayIndex);
    },

    toString: function () {
        return '[Collection]';
    }
});


@@ -1,28 +1,23 @@
 import 
-Array
 Iterable
  from '.
@@ -8,16 +8,125 @@
 Iterable
+ from '../iteration/iterable';%0Aimport ArrayIterator from '../iteration/iterator-array';%0Aimport iterableSymbol
  from '.
@@ -146,21 +146,22 @@
 terable-
-array
+symbol
 ';%0Aimpor
@@ -297,16 +297,17 @@
 ike from
+ 
 '../util
@@ -329,16 +329,17 @@
 ';%0A%0A/**%0A
+ 
 * Initia
@@ -393,16 +393,17 @@
  class.%0A
+ 
 */%0Aexpor
@@ -561,21 +561,16 @@
  %7D%0A%0A    
-Array
 Iterable
@@ -611,21 +611,16 @@
 ection, 
-Array
 Iterable
@@ -635,16 +635,17 @@
 /**%0A    
+ 
 * Gets t
@@ -699,16 +699,17 @@
 on.%0A    
+ 
 * @retur
@@ -720,16 +720,17 @@
 Number%7D%0A
+ 
     */%0A 
@@ -811,16 +811,17 @@
 /**%0A    
+ 
 * Copies
@@ -913,16 +913,17 @@
  index.%0A
+ 
     * @p
@@ -1027,24 +1027,25 @@
 Collection.%0A
+ 
     * @param
@@ -1120,24 +1120,25 @@
 begins.%0A    
+ 
 */%0A    copyT
@@ -1240,70 +1240,316 @@
     
-toString: function () %7B%0A        return '%5BCollection%5D';%0A    %7D%0A%7D);%0A%0A
+/**%0A    * Creates an array from the Iterable.%0A    * @returns %7BArray%7D%0A    */%0A    toArray: function () %7B%0A        return this%5BiterableSymbol%5D %7C%7C %5B%5D;%0A    %7D,%0A%0A    toString: function () %7B%0A        return '%5BCollection%5D';%0A    %7D,%0A%0A    '@@iterator': function () %7B%0A        return new ArrayIterator(this.toArray());%0A    %7D%0A%7D);

extend Collection from Iterable