base/common/src/main/com/thesett/common/util/AbstractHeap.java
public Object[] toArray()
    {
        Object[] result = new Object[size()];

        Iterator<E> e = iterator();

        for (int i = 0; e.hasNext(); i++)
        {
            result[i] = e.next();
        }

        return result;
    }
public Object[] toArray()
    {
        Object[] result = new Object[size()];

        Iterator<E> e = iterator();

        for (int i = 0; e.hasNext(); i++)
        {
            result[i] = e.next();
        }

        return result;
    }
public Object [ ] toArray ( ) { Object [ ] result = new Object [ size ( ) ] ; Iterator < E > e = iterator ( ) ; for ( int i = 0 ; e . hasNext ( ) ; i ++ ) { result [ i ] = e . next ( ) ; } return result ; }
Returns an array containing all of the elements in this heap. If the collection makes any guarantees as to what
order its elements are returned by its iterator, this method must return the elements in the same order. The
returned array will be "safe" in that no references to it are maintained by the collection. (In other words, this
method must allocate a new array even if the collection is backed by an Array). The caller is thus free to modify
the returned array.

<p>This implementation allocates the array to be returned, and iterates over the elements in the collection,
storing each object reference in the next consecutive element of the array, starting with element 0.

@return an array containing all of the elements in this collection.
Returns an array containing all of the elements in this heap . If the collection makes any guarantees as to what order its elements are returned by its iterator this method must return the elements in the same order . The returned array will be safe in that no references to it are maintained by the collection . ( In other words this method must allocate a new array even if the collection is backed by an Array ) . The caller is thus free to modify the returned array .