com.github.andyshao.lang.IntLongWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Gear Show documentation
Show all versions of Gear Show documentation
Enhance and formating the coding of JDK
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 IntLongWrapper implements LongWrapper {
private static final int BASE = 1;
@Override
public long getLong(int[] array , BigInteger position) {
long result = 0x00;
for (int i = 0 , index = position.intValue() << IntLongWrapper.BASE ; i < 2 ; i++ , index++)
if (array.length > index) result = LongOperation.setInt(result , i , array[index]);
else if (i == 0) throw new ArrayIndexOutOfBoundsException(index);
else break;
return result;
}
@Override
public void setLong(int[] array , BigInteger position , long l) {
for (int i = 0 , index = position.intValue() << IntLongWrapper.BASE ; i < 2 ; i++ , index++)
if (array.length > index) array[index] = LongOperation.getInt(l , i);
else if (i == 0) throw new ArrayIndexOutOfBoundsException(index);
else break;
}
@Override
public BigInteger size(int[] array) {
return array.length - (array.length >> IntLongWrapper.BASE) > 0 ? BigInteger.valueOf((array.length >> IntLongWrapper.BASE) + 1) : BigInteger.valueOf(array.length >> IntLongWrapper.BASE);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy