Yes.

        public Object[] toArray() {
            checkForComodification();
            return Arrays.copyOfRange(root.elementData, offset, offset +
size);
        }

        @SuppressWarnings("unchecked")
        public <T> T[] toArray(T[] a) {
            checkForComodification();
            if (a.length < size)
                return (T[]) Arrays.copyOfRange(
                        root.elementData, offset, offset + size,
a.getClass());
            System.arraycopy(root.elementData, offset, a, 0, size);
            if (a.length > size)
                a[size] = null;
            return a;
        }

It's still possible to find simple performance improvements in classes like
ArrayList.

On Thu, Jan 25, 2018 at 4:41 PM, John Rose <[email protected]> wrote:

> On Jan 25, 2018, at 2:02 PM, Сергей Цыпанов <[email protected]>
> wrote:
> >
> > +                return (T[]) Arrays.copyOfRange(root.elementData,
> offset, size, a.getClass());
>
>
> Giving this a quick glance:
> I think you may want s/size/offset+size/.
> There should be calls to checkForComodification.
>
>

Reply via email to