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

com.github.andyshao.lang.IntShortWrapper Maven / Gradle / Ivy

The newest version!
package com.github.andyshao.lang;

import java.math.BigInteger;

/**
 * 
 * Title:
* Descript:
* Copyright: Copryright(c) Apr 5, 2015
* Encoding:UNIX UTF-8 * * @author Andy.Shao * */ public class IntShortWrapper implements ShortWrapper { private static final BigInteger BASE = BigInteger.valueOf(2); @Override public short getShort(int[] array , BigInteger position) { BigInteger indexs[] = position.divideAndRemainder(IntShortWrapper.BASE); if (indexs[1].intValue() < 0) throw new ArrayIndexOutOfBoundsException(position.toString()); return IntegerOperation.getShort(array[indexs[0].intValue()] , indexs[1].intValue()); } @Override public void setShort(int[] array , BigInteger position , short s) { BigInteger indexs[] = position.divideAndRemainder(IntShortWrapper.BASE); if (indexs[1].intValue() < 0) throw new ArrayIndexOutOfBoundsException(position.toString()); array[indexs[0].intValue()] = IntegerOperation.setShort(array[indexs[0].intValue()] , indexs[1].intValue() , s); } @Override public BigInteger size(int[] array) { return BigInteger.valueOf(array.length).multiply(IntShortWrapper.BASE); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy