All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lwjgl.system.CheckIntrinsics Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
/*
 * Copyright LWJGL. All rights reserved.
 * License terms: https://www.lwjgl.org/license
 */
package org.lwjgl.system;

/**
 * Simple index checks.
 *
 * 

On Java 9 these checks are replaced with the corresponding {@link java.util.Objects} methods, which perform better.

*/ public final class CheckIntrinsics { private CheckIntrinsics() { } public static int checkIndex(int index, int length) { if (index < 0 || length <= index) { throw new IndexOutOfBoundsException(); } return index; } public static int checkFromToIndex(int fromIndex, int toIndex, int length) { if (fromIndex < 0 || toIndex < fromIndex || length < toIndex) { throw new IndexOutOfBoundsException(); } return fromIndex; } public static int checkFromIndexSize(int fromIndex, int size, int length) { if ((length | fromIndex | size) < 0 || length - fromIndex < size) { throw new IndexOutOfBoundsException(); } return fromIndex; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy