类java.lang.IndexOutOfBoundsException源码实例Demo

下面列出了怎么用java.lang.IndexOutOfBoundsException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pluotsorbet   文件: constructor.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    IndexOutOfBoundsException object1 = new IndexOutOfBoundsException();
    harness.check(object1 != null);
    harness.check(object1.toString(), "java.lang.IndexOutOfBoundsException");

    IndexOutOfBoundsException object2 = new IndexOutOfBoundsException("nothing happens");
    harness.check(object2 != null);
    harness.check(object2.toString(), "java.lang.IndexOutOfBoundsException: nothing happens");

    IndexOutOfBoundsException object3 = new IndexOutOfBoundsException(null);
    harness.check(object3 != null);
    harness.check(object3.toString(), "java.lang.IndexOutOfBoundsException");

}
 
源代码2 项目: openjdk-jdk9   文件: ParsingTest.java
private static void checkIndexOutOfBoundsException(String val, int start, int end, int radix) {
    int n = 0;
    try {
        n = Integer.parseInt(val, start, end, radix);
        System.err.println("parseInt(" + val + ", " + start + ", " + end + ", " + radix  +
                ") incorrectly returned " + n);
        throw new RuntimeException();
    } catch (IndexOutOfBoundsException ioob) {
        ; // Expected
    }
}
 
源代码3 项目: SkyTube   文件: TouchableMovementMethod.java
/**
 * Find the span that was clicked
 *
 * @param widget    view the user clicked
 * @param spannable spannable string inside the clicked view
 * @param event     motion event that occurred
 * @return the touchable span that was pressed
 */
private URLSpan getPressedSpan(TextView widget, Spannable spannable, MotionEvent event) {
    int x = Math.round(event.getX());
    int y = Math.round(event.getY());

    x -= widget.getTotalPaddingLeft();
    y -= widget.getTotalPaddingTop();

    x += widget.getScrollX();
    y += widget.getScrollY();

    Layout layout = widget.getLayout();
    int line = layout.getLineForVertical(y);

    int off;
    try {
        off = layout.getOffsetForHorizontal(line, (float) x);
    } catch (IndexOutOfBoundsException e) {
        return null;
    }

    int end = layout.getLineEnd(line);

    // offset seems like it can be one off in some cases
    // Could be what was causing issue 7 in the first place:
    // https://github.com/klinker24/Android-TextView-LinkBuilder/issues/7
    if (off != end && off != end - 1) {
        URLSpan[] links = spannable.getSpans(off, off, URLSpan.class);

        if (links.length > 0) {
            return links[0];
        }
    }

    return null;
}
 
源代码4 项目: translationstudio8   文件: FastLongBuffer.java
/**
 * Get the long val at given index value.
 * @return long
 * @param index int
 */
public long longAt(int index) {
    if (index < 0 || index > size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum = (index >> exp);
    // int offset = index % r;
    int offset = index &r;
    return ((long[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码5 项目: translationstudio8   文件: FastLongBuffer.java
/**
 * Get the lower 32 bit of the integer at the given index.
 * @return int
 * @param index int
 */
 public int lower32At(int index) {
    if (index < 0 || index > size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum =  (index >> exp);
    // int offset = index % pageSize;
    int offset = index & r;
    return (int) ((long[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码6 项目: translationstudio8   文件: FastLongBuffer.java
/**
 * Modify the value at the index to a new val.
 * @param index int
 * @param newValue long
 */
public void modifyEntry(int index, long newValue) {

    if (index < 0 || index > size + 1) {
        throw new IndexOutOfBoundsException();
    }
    //((long[]) bufferArrayList.get((int) (index / pageSize)))[index % pageSize] =
    ((long[]) bufferArrayList.get(index >> exp))[index & r] =
        newValue;
}
 
源代码7 项目: translationstudio8   文件: FastLongBuffer.java
/**
 * Return the upper 32 bit of the long at the index.
 * @return int
 * @param index int
 */
public int upper32At(int index) {
    if (index < 0 || index >= size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum = (index >>exp);
    int offset = index & r;
    return (int)
        ((((long[]) bufferArrayList.get(pageNum))[offset] & (0xffffffffL << 32)) >> 32);

}
 
源代码8 项目: translationstudio8   文件: FastIntBuffer.java
/**
 * Get the int at the location specified by index.
 * @return int
 * @param index int
 */
public int intAt(int index) {
    if (index < 0 || index > size()-1) {
        throw new IndexOutOfBoundsException();
    }
//    int pageNum = (int) index / pageSize;
    int pageNum = index>>exp;
    //System.out.println("page Number is "+pageNum); 
//    int offset = index % pageSize;
    int offset = index & r;
    return ((int[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码9 项目: translationstudio8   文件: FastIntBuffer.java
/**
 * Assigns a new int value to location index of the buffer instance.
 * @param index int
 * @param newValue int
 */
public void modifyEntry(int index, int newValue) {
	
        if (index < 0 || index > size - 1) {
            throw new IndexOutOfBoundsException();
        }

//        ((int[]) bufferArrayList.get((int) (index / pageSize)))[index % pageSize] =
        ((int[]) bufferArrayList.get((index >> exp)))[index & r] =
            newValue;
	
	}
 
源代码10 项目: pluotsorbet   文件: TryCatch.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    // flag that is set when exception is caught
    boolean caught = false;
    try {
        throw new IndexOutOfBoundsException("IndexOutOfBoundsException");
    }
    catch (IndexOutOfBoundsException e) {
        // correct exception was caught
        caught = true;
    }
    harness.check(caught);
}
 
源代码11 项目: tmxeditor8   文件: FastLongBuffer.java
/**
 * Get the long val at given index value.
 * @return long
 * @param index int
 */
public long longAt(int index) {
    if (index < 0 || index > size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum = (index >> exp);
    // int offset = index % r;
    int offset = index &r;
    return ((long[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码12 项目: tmxeditor8   文件: FastLongBuffer.java
/**
 * Get the lower 32 bit of the integer at the given index.
 * @return int
 * @param index int
 */
 public int lower32At(int index) {
    if (index < 0 || index > size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum =  (index >> exp);
    // int offset = index % pageSize;
    int offset = index & r;
    return (int) ((long[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码13 项目: tmxeditor8   文件: FastLongBuffer.java
/**
 * Modify the value at the index to a new val.
 * @param index int
 * @param newValue long
 */
public void modifyEntry(int index, long newValue) {

    if (index < 0 || index > size + 1) {
        throw new IndexOutOfBoundsException();
    }
    //((long[]) bufferArrayList.get((int) (index / pageSize)))[index % pageSize] =
    ((long[]) bufferArrayList.get(index >> exp))[index & r] =
        newValue;
}
 
源代码14 项目: tmxeditor8   文件: FastLongBuffer.java
/**
 * Return the upper 32 bit of the long at the index.
 * @return int
 * @param index int
 */
public int upper32At(int index) {
    if (index < 0 || index >= size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum = (index >>exp);
    int offset = index & r;
    return (int)
        ((((long[]) bufferArrayList.get(pageNum))[offset] & (0xffffffffL << 32)) >> 32);

}
 
源代码15 项目: tmxeditor8   文件: FastIntBuffer.java
/**
 * Get the int at the location specified by index.
 * @return int
 * @param index int
 */
public int intAt(int index) {
    if (index < 0 || index > size()-1) {
        throw new IndexOutOfBoundsException();
    }
//    int pageNum = (int) index / pageSize;
    int pageNum = index>>exp;
    //System.out.println("page Number is "+pageNum); 
//    int offset = index % pageSize;
    int offset = index & r;
    return ((int[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码16 项目: tmxeditor8   文件: FastIntBuffer.java
/**
 * Assigns a new int value to location index of the buffer instance.
 * @param index int
 * @param newValue int
 */
public void modifyEntry(int index, int newValue) {
	
        if (index < 0 || index > size - 1) {
            throw new IndexOutOfBoundsException();
        }

//        ((int[]) bufferArrayList.get((int) (index / pageSize)))[index % pageSize] =
        ((int[]) bufferArrayList.get((index >> exp)))[index & r] =
            newValue;
	
	}
 
源代码17 项目: vtd-xml   文件: FastLongBuffer.java
/**
 * Get the long val at given index value.
 * @return long
 * @param index int
 */
public long longAt(int index) {
    if (index < 0 || index > size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum = (index >> exp);
    // int offset = index % r;
    int offset = index &r;
    return ((long[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码18 项目: vtd-xml   文件: FastLongBuffer.java
/**
 * Get the lower 32 bit of the integer at the given index.
 * @return int
 * @param index int
 */
 public int lower32At(int index) {
    if (index < 0 || index > size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum =  (index >> exp);
    // int offset = index % pageSize;
    int offset = index & r;
    return (int) ((long[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码19 项目: vtd-xml   文件: FastLongBuffer.java
/**
 * Modify the value at the index to a new val.
 * @param index int
 * @param newValue long
 */
public void modifyEntry(int index, long newValue) {

    if (index < 0 || index > size + 1) {
        throw new IndexOutOfBoundsException();
    }
    //((long[]) bufferArrayList.get((int) (index / pageSize)))[index % pageSize] =
    ((long[]) bufferArrayList.get(index >> exp))[index & r] =
        newValue;
}
 
源代码20 项目: vtd-xml   文件: FastLongBuffer.java
/**
 * Return the upper 32 bit of the long at the index.
 * @return int
 * @param index int
 */
public int upper32At(int index) {
    if (index < 0 || index >= size()) {
        throw new IndexOutOfBoundsException();
    }
    int pageNum = (index >>exp);
    int offset = index & r;
    return (int)
        ((((long[]) bufferArrayList.get(pageNum))[offset] & (0xffffffffL << 32)) >> 32);

}
 
源代码21 项目: vtd-xml   文件: FastIntBuffer.java
/**
 * Get the int at the location specified by index.
 * @return int
 * @param index int
 */
public int intAt(int index) {
    if (index < 0 || index > size()-1) {
        throw new IndexOutOfBoundsException();
    }
//    int pageNum = (int) index / pageSize;
    int pageNum = index>>exp;
    //System.out.println("page Number is "+pageNum); 
//    int offset = index % pageSize;
    int offset = index & r;
    return ((int[]) bufferArrayList.get(pageNum))[offset];
}
 
源代码22 项目: vtd-xml   文件: FastIntBuffer.java
/**
 * Assigns a new int value to location index of the buffer instance.
 * @param index int
 * @param newValue int
 */
public void modifyEntry(int index, int newValue) {
	
        if (index < 0 || index > size - 1) {
            throw new IndexOutOfBoundsException();
        }

//        ((int[]) bufferArrayList.get((int) (index / pageSize)))[index % pageSize] =
        ((int[]) bufferArrayList.get((index >> exp)))[index & r] =
            newValue;
	
	}
 
源代码23 项目: FastAsyncWorldedit   文件: ZstdInputStream.java
public int read(byte[] dst, int offset, int len) throws IOException {

        if (isClosed) {
            throw new IOException("Stream closed");
        }

        // guard agains buffer overflows
        if (offset < 0 || len > dst.length - offset) {
            throw new IndexOutOfBoundsException("Requested lenght " + len
                    + " from offset " + offset + " in buffer of size " + dst.length);
        }
        int dstSize = offset + len;
        dstPos = offset;

        while (dstPos < dstSize) {
            if (srcSize - srcPos == 0) {
                srcSize = in.read(src, 0, srcBuffSize);
                srcPos = 0;
                if (srcSize < 0) {
                    srcSize = 0;
                    if (frameFinished) {
                        return -1;
                    } else if (isContinuous) {
                        return (int)(dstPos - offset);
                    } else {
                        throw new IOException("Read error or truncated source");
                    }
                }
                frameFinished = false;
            }

            int size = decompressStream(stream, dst, dstSize, src, (int) srcSize);

            if (Zstd.isError(size)) {
                throw new IOException("Decompression error: " + Zstd.getErrorName(size));
            }

            // we have completed a frame
            if (size == 0) {
                frameFinished = true;
                // re-init the codec so it can start decoding next frame
                size = initDStream(stream);
                if (Zstd.isError(size)) {
                    throw new IOException("Decompression error: " + Zstd.getErrorName(size));
                }
                return (int)(dstPos - offset);
            }
        }
        return len;
    }
 
源代码24 项目: translationstudio8   文件: FastLongBuffer.java
/**
 * Return a selected chuck of long buffer as a long array.
 * @return long[]
 * @param startingOffset int
 * @param len int
 */
public long[] getLongArray(int startingOffset, int len) {
    if (size <= 0 || startingOffset < 0) {
        throw (new IllegalArgumentException());
    }
    if ((startingOffset + len) > size) {
        throw (new IndexOutOfBoundsException());
    }

    long[] result = new long[len]; // allocate result array

    int first_index =  (startingOffset >> exp);
    int last_index = ((startingOffset + len) >>exp);

    //if ((startingOffset + len) % pageSize == 0) {
    if (((startingOffset + len) & r) == 0) {
        last_index--;
    }

    if (first_index == last_index) {
        // to see if there is a need to go across buffer boundry
        System.arraycopy(
            (long[]) (bufferArrayList.oa[first_index]),
//            startingOffset % pageSize,
			startingOffset & r,
            result,
            0,
            len);
    } else {
        int long_array_offset = 0;
        for (int i = first_index; i <= last_index; i++) {
            long[] currentChunk = (long[]) bufferArrayList.oa[i];
            if (i == first_index) // first section
                {
                System.arraycopy(
                    currentChunk,
//                  startingOffset % pageSize,
        			startingOffset & r,
                    result,
                    0,
//                  pageSize - (startingOffset % r));
					pageSize - (startingOffset & r));
                long_array_offset += pageSize - (startingOffset & r);
            } else if (i == last_index) // last sections
                {
                System.arraycopy(
                    currentChunk,
                    0,
                    result,
                    long_array_offset,
                    len - long_array_offset);

            } else {
                System.arraycopy(currentChunk, 0, result, long_array_offset, pageSize);
                long_array_offset += pageSize;
            }
        }
    }

    return result;
}
 
源代码25 项目: translationstudio8   文件: FastIntBuffer.java
/**
 * Returns a single int array representing every int in this buffer instance
 * @return int[]  (null if there isn't anything left in the buffer   
 * @param startingOffset int
 * @param len int
 * @return int[]
 */
public int[] getIntArray(int startingOffset, int len) {
    if (size <= 0 || startingOffset < 0) {
        throw (new IllegalArgumentException());
    }
    if ((startingOffset + len) > size) {
        throw (new IndexOutOfBoundsException());
    }
    int[] result = new int[len]; // allocate result array

//    int first_index = (int) (startingOffset / pageSize);
//    int last_index = (int) ((startingOffset + len) / pageSize);
//    if ((startingOffset + len) % pageSize == 0) {
//        last_index--;
//    }
    int first_index = startingOffset >> exp;
    int last_index = (startingOffset + len)>> exp;
    if (((startingOffset + len) & r) == 0) {
        last_index--;
    }

    if (first_index == last_index) {
        // to see if there is a need to go across buffer boundry
        System.arraycopy(
            (int[]) (bufferArrayList.get(first_index)),
//            startingOffset % pageSize,
            startingOffset & r,
            result,
            0,
            len);
    } else {
        int int_array_offset = 0;
        for (int i = first_index; i <= last_index; i++) {
            int[] currentChunk = (int[]) bufferArrayList.get(i);
            if (i == first_index) // first section
                {
                System.arraycopy(
                    currentChunk,
//                  startingOffset % pageSize,
                    startingOffset & r,
                    result,
                    0,
//                  pageSize - (startingOffset % pageSize));
                    pageSize - (startingOffset & r));
//                int_array_offset += pageSize - (startingOffset) % pageSize;
                int_array_offset += pageSize - (startingOffset & r);
            } else if (i == last_index) // last sections
                {
                System.arraycopy(
                    currentChunk,
                    0,
                    result,
                    int_array_offset,
                    len - int_array_offset);

            } else {
                System.arraycopy(currentChunk, 0, result, int_array_offset, pageSize);
                int_array_offset += pageSize;
            }
        }
    }
    return result;
}
 
源代码26 项目: translationstudio8   文件: FastLongBuffer.java
/**
 * Return a selected chuck of long buffer as a long array.
 * @return long[]
 * @param startingOffset int
 * @param len int
 */
public long[] getLongArray(int startingOffset, int len) {
    if (size <= 0 || startingOffset < 0) {
        throw (new IllegalArgumentException());
    }
    if ((startingOffset + len) > size()) {
        throw (new IndexOutOfBoundsException());
    }

    long[] result = new long[len]; // allocate result array

    int first_index =  (startingOffset >> exp);
    int last_index = ((startingOffset + len) >>exp);

    //if ((startingOffset + len) % pageSize == 0) {
    if (((startingOffset + len) & r) == 0) {
        last_index--;
    }

    if (first_index == last_index) {
        // to see if there is a need to go across buffer boundry
        System.arraycopy(
            (long[]) (bufferArrayList.get(first_index)),
//            startingOffset % pageSize,
			startingOffset & r,
            result,
            0,
            len);
    } else {
        int long_array_offset = 0;
        for (int i = first_index; i <= last_index; i++) {
            long[] currentChunk = (long[]) bufferArrayList.get(i);
            if (i == first_index) // first section
                {
                System.arraycopy(
                    currentChunk,
//                  startingOffset % pageSize,
        			startingOffset & r,
                    result,
                    0,
//                  pageSize - (startingOffset % r));
					pageSize - (startingOffset & r));
                long_array_offset += pageSize - (startingOffset & r);
            } else if (i == last_index) // last sections
                {
                System.arraycopy(
                    currentChunk,
                    0,
                    result,
                    long_array_offset,
                    len - long_array_offset);

            } else {
                System.arraycopy(currentChunk, 0, result, long_array_offset, pageSize);
                long_array_offset += pageSize;
            }
        }
    }

    return result;
}
 
源代码27 项目: translationstudio8   文件: FastIntBuffer.java
/**
 * Returns a single int array representing every int in this buffer instance
 * @return int[]  (null if there isn't anything left in the buffer   
 * @param startingOffset int
 * @param len int
 * @return int[]
 */
public int[] getIntArray(int startingOffset, int len) {
    if (size <= 0 || startingOffset < 0) {
        throw (new IllegalArgumentException());
    }
    if ((startingOffset + len) > size()) {
        throw (new IndexOutOfBoundsException());
    }
    int[] result = new int[len]; // allocate result array

//    int first_index = (int) (startingOffset / pageSize);
//    int last_index = (int) ((startingOffset + len) / pageSize);
//    if ((startingOffset + len) % pageSize == 0) {
//        last_index--;
//    }
    int first_index = startingOffset >> exp;
    int last_index = (startingOffset + len)>> exp;
    if (((startingOffset + len) & r) == 0) {
        last_index--;
    }

    if (first_index == last_index) {
        // to see if there is a need to go across buffer boundry
        System.arraycopy(
            (int[]) (bufferArrayList.get(first_index)),
//            startingOffset % pageSize,
            startingOffset & r,
            result,
            0,
            len);
    } else {
        int int_array_offset = 0;
        for (int i = first_index; i <= last_index; i++) {
            int[] currentChunk = (int[]) bufferArrayList.get(i);
            if (i == first_index) // first section
                {
                System.arraycopy(
                    currentChunk,
//                  startingOffset % pageSize,
                    startingOffset & r,
                    result,
                    0,
//                  pageSize - (startingOffset % pageSize));
                    pageSize - (startingOffset & r));
//                int_array_offset += pageSize - (startingOffset) % pageSize;
                int_array_offset += pageSize - (startingOffset & r);
            } else if (i == last_index) // last sections
                {
                System.arraycopy(
                    currentChunk,
                    0,
                    result,
                    int_array_offset,
                    len - int_array_offset);

            } else {
                System.arraycopy(currentChunk, 0, result, int_array_offset, pageSize);
                int_array_offset += pageSize;
            }
        }
    }
    return result;
}
 
源代码28 项目: tmxeditor8   文件: FastLongBuffer.java
/**
 * Return a selected chuck of long buffer as a long array.
 * @return long[]
 * @param startingOffset int
 * @param len int
 */
public long[] getLongArray(int startingOffset, int len) {
    if (size <= 0 || startingOffset < 0) {
        throw (new IllegalArgumentException());
    }
    if ((startingOffset + len) > size) {
        throw (new IndexOutOfBoundsException());
    }

    long[] result = new long[len]; // allocate result array

    int first_index =  (startingOffset >> exp);
    int last_index = ((startingOffset + len) >>exp);

    //if ((startingOffset + len) % pageSize == 0) {
    if (((startingOffset + len) & r) == 0) {
        last_index--;
    }

    if (first_index == last_index) {
        // to see if there is a need to go across buffer boundry
        System.arraycopy(
            (long[]) (bufferArrayList.oa[first_index]),
//            startingOffset % pageSize,
			startingOffset & r,
            result,
            0,
            len);
    } else {
        int long_array_offset = 0;
        for (int i = first_index; i <= last_index; i++) {
            long[] currentChunk = (long[]) bufferArrayList.oa[i];
            if (i == first_index) // first section
                {
                System.arraycopy(
                    currentChunk,
//                  startingOffset % pageSize,
        			startingOffset & r,
                    result,
                    0,
//                  pageSize - (startingOffset % r));
					pageSize - (startingOffset & r));
                long_array_offset += pageSize - (startingOffset & r);
            } else if (i == last_index) // last sections
                {
                System.arraycopy(
                    currentChunk,
                    0,
                    result,
                    long_array_offset,
                    len - long_array_offset);

            } else {
                System.arraycopy(currentChunk, 0, result, long_array_offset, pageSize);
                long_array_offset += pageSize;
            }
        }
    }

    return result;
}
 
源代码29 项目: tmxeditor8   文件: FastIntBuffer.java
/**
 * Returns a single int array representing every int in this buffer instance
 * @return int[]  (null if there isn't anything left in the buffer   
 * @param startingOffset int
 * @param len int
 * @return int[]
 */
public int[] getIntArray(int startingOffset, int len) {
    if (size <= 0 || startingOffset < 0) {
        throw (new IllegalArgumentException());
    }
    if ((startingOffset + len) > size) {
        throw (new IndexOutOfBoundsException());
    }
    int[] result = new int[len]; // allocate result array

//    int first_index = (int) (startingOffset / pageSize);
//    int last_index = (int) ((startingOffset + len) / pageSize);
//    if ((startingOffset + len) % pageSize == 0) {
//        last_index--;
//    }
    int first_index = startingOffset >> exp;
    int last_index = (startingOffset + len)>> exp;
    if (((startingOffset + len) & r) == 0) {
        last_index--;
    }

    if (first_index == last_index) {
        // to see if there is a need to go across buffer boundry
        System.arraycopy(
            (int[]) (bufferArrayList.get(first_index)),
//            startingOffset % pageSize,
            startingOffset & r,
            result,
            0,
            len);
    } else {
        int int_array_offset = 0;
        for (int i = first_index; i <= last_index; i++) {
            int[] currentChunk = (int[]) bufferArrayList.get(i);
            if (i == first_index) // first section
                {
                System.arraycopy(
                    currentChunk,
//                  startingOffset % pageSize,
                    startingOffset & r,
                    result,
                    0,
//                  pageSize - (startingOffset % pageSize));
                    pageSize - (startingOffset & r));
//                int_array_offset += pageSize - (startingOffset) % pageSize;
                int_array_offset += pageSize - (startingOffset & r);
            } else if (i == last_index) // last sections
                {
                System.arraycopy(
                    currentChunk,
                    0,
                    result,
                    int_array_offset,
                    len - int_array_offset);

            } else {
                System.arraycopy(currentChunk, 0, result, int_array_offset, pageSize);
                int_array_offset += pageSize;
            }
        }
    }
    return result;
}
 
源代码30 项目: tmxeditor8   文件: FastLongBuffer.java
/**
 * Return a selected chuck of long buffer as a long array.
 * @return long[]
 * @param startingOffset int
 * @param len int
 */
public long[] getLongArray(int startingOffset, int len) {
    if (size <= 0 || startingOffset < 0) {
        throw (new IllegalArgumentException());
    }
    if ((startingOffset + len) > size()) {
        throw (new IndexOutOfBoundsException());
    }

    long[] result = new long[len]; // allocate result array

    int first_index =  (startingOffset >> exp);
    int last_index = ((startingOffset + len) >>exp);

    //if ((startingOffset + len) % pageSize == 0) {
    if (((startingOffset + len) & r) == 0) {
        last_index--;
    }

    if (first_index == last_index) {
        // to see if there is a need to go across buffer boundry
        System.arraycopy(
            (long[]) (bufferArrayList.get(first_index)),
//            startingOffset % pageSize,
			startingOffset & r,
            result,
            0,
            len);
    } else {
        int long_array_offset = 0;
        for (int i = first_index; i <= last_index; i++) {
            long[] currentChunk = (long[]) bufferArrayList.get(i);
            if (i == first_index) // first section
                {
                System.arraycopy(
                    currentChunk,
//                  startingOffset % pageSize,
        			startingOffset & r,
                    result,
                    0,
//                  pageSize - (startingOffset % r));
					pageSize - (startingOffset & r));
                long_array_offset += pageSize - (startingOffset & r);
            } else if (i == last_index) // last sections
                {
                System.arraycopy(
                    currentChunk,
                    0,
                    result,
                    long_array_offset,
                    len - long_array_offset);

            } else {
                System.arraycopy(currentChunk, 0, result, long_array_offset, pageSize);
                long_array_offset += pageSize;
            }
        }
    }

    return result;
}
 
 类所在包
 同包方法