Java Array Copy arraycopy(long src[], int srcOffset, long dest[], int destOffset, int limit)

Here you can find the source of arraycopy(long src[], int srcOffset, long dest[], int destOffset, int limit)

Description

arraycopy

License

Open Source License

Declaration

public static final void arraycopy(long src[], int srcOffset, long dest[], int destOffset, int limit) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final void arraycopy(long src[], int srcOffset, long dest[], int destOffset, int limit) {
        if (src == dest) {
            if (srcOffset == destOffset) {
                return;
            }//w  w  w.j  av  a2s . c om

            if (destOffset > srcOffset && destOffset < srcOffset + limit) {
                limit--;
                srcOffset += limit;
                destOffset += limit;
                limit = srcOffset - limit;

                for (limit += 3; srcOffset >= limit;) {
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                }

                for (limit -= 3; srcOffset >= limit;) {
                    dest[destOffset--] = src[srcOffset--];
                }
                return;
            }
        }
        limit += srcOffset;

        for (limit -= 3; srcOffset < limit;) {
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
        }

        for (limit += 3; srcOffset < limit;) {
            dest[destOffset++] = src[srcOffset++];
        }
    }

    public static final void arraycopy(short src[], int srcOffset, short dest[], int destOffset, int k) {
        if (src == dest) {
            if (srcOffset == destOffset) {
                return;
            }

            if (destOffset > srcOffset && destOffset < srcOffset + k) {
                k--;
                srcOffset += k;
                destOffset += k;
                k = srcOffset - k;

                for (k += 7; srcOffset >= k;) {
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                }

                for (k -= 7; srcOffset >= k;) {
                    dest[destOffset--] = src[srcOffset--];
                }
                return;
            }
        }
        k += srcOffset;

        for (k -= 7; srcOffset < k;) {
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
        }

        for (k += 7; srcOffset < k;) {
            dest[destOffset++] = src[srcOffset++];
        }
    }

    public static final void arraycopy(int src[], int srcOffset, int dest[], int destOffset, int k) {
        if (src == dest) {
            if (srcOffset == destOffset) {
                return;
            }

            if (destOffset > srcOffset && destOffset < srcOffset + k) {
                k--;
                srcOffset += k;
                destOffset += k;
                k = srcOffset - k;

                for (k += 7; srcOffset >= k;) {
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                }

                for (k -= 7; srcOffset >= k;) {
                    dest[destOffset--] = src[srcOffset--];
                }

                return;
            }
        }
        k += srcOffset;

        for (k -= 7; srcOffset < k;) {
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
        }

        for (k += 7; srcOffset < k;) {
            dest[destOffset++] = src[srcOffset++];
        }
    }

    public static final void arraycopy(Object src[], int srcOffset, Object dest[], int destOffset, int limit) {
        if (src == dest) {
            if (srcOffset == destOffset) {
                return;
            }

            if (destOffset > srcOffset && destOffset < srcOffset + limit) {
                limit--;
                srcOffset += limit;
                destOffset += limit;
                limit = srcOffset - limit;

                for (limit += 7; srcOffset >= limit;) {
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                }

                for (limit -= 7; srcOffset >= limit;) {
                    dest[destOffset--] = src[srcOffset--];
                }

                return;
            }
        }
        limit += srcOffset;

        for (limit -= 7; srcOffset < limit;) {
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
        }

        for (limit += 7; srcOffset < limit;) {
            dest[destOffset++] = src[srcOffset++];
        }
    }

    public static final void arraycopy(byte src[], int srcOffset, byte dest[], int destOffset, int limit) {
        if (src == dest) {
            if (srcOffset == destOffset) {
                return;
            }

            if (destOffset > srcOffset && destOffset < srcOffset + limit) {
                limit--;
                srcOffset += limit;
                destOffset += limit;
                limit = srcOffset - limit;

                for (limit += 7; srcOffset >= limit;) {
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                    dest[destOffset--] = src[srcOffset--];
                }

                for (limit -= 7; srcOffset >= limit;) {
                    dest[destOffset--] = src[srcOffset--];
                }
                return;
            }
        }
        limit += srcOffset;

        for (limit -= 7; srcOffset < limit;) {
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
            dest[destOffset++] = src[srcOffset++];
        }

        for (limit += 7; srcOffset < limit;) {
            dest[destOffset++] = src[srcOffset++];
        }
    }
}

Related

  1. arrayCopy(final float[] arrayToCopy)
  2. arrayCopy(int[] array, int i0, int n, boolean isReverse)
  3. arrayCopy(int[] array, int length)
  4. arrayCopy(int[] x)
  5. arrayCopy(int[][] source, int[][] destination)
  6. arraycopy(long[] src, int srcPos, long[] dest, int destPos, int length)
  7. arraycopy(Object dest, Object src1, int length1, Object src2, int length2)
  8. arrayCopy(Object src, int srcPos, Object dest, int destPos, int length)
  9. arraycopy(Object src, int srcPos, Object dest, int destPos, int length)