本文整理汇总了Java中com.google.common.primitives.SignedBytes类的典型用法代码示例。如果您正苦于以下问题:Java SignedBytes类的具体用法?Java SignedBytes怎么用?Java SignedBytes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SignedBytes类属于com.google.common.primitives包,在下文中一共展示了SignedBytes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TileEntityRenderDisplay
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
public TileEntityRenderDisplay() {
itemRender = new RenderEntityItem(Minecraft.getMinecraft().getRenderManager(), Minecraft.getMinecraft().getRenderItem()) {
@Override
protected int getModelCount(ItemStack stack) {
return SignedBytes.saturatedCast(Math.min(stack.getCount() / 32, 15) + 1);
}
@Override
public boolean shouldBob() {
return false;
}
@Override
public boolean shouldSpreadItems() {
return false;
}
};
}
示例2: writeTo
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
/**
* Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
* serialization). This has been measured to save at least 400 bytes compared to regular
* serialization.
*
* <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
*/
public void writeTo(OutputStream out) throws IOException {
// Serial form:
// 1 signed byte for the strategy
// 1 unsigned byte for the number of hash functions
// 1 big endian int, the number of longs in our bitset
// N big endian longs of our bitset
DataOutputStream dout = new DataOutputStream(out);
dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
dout.writeInt(bits.data.length);
for (long value : bits.data) {
dout.writeLong(value);
}
}
示例3: writeTo
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
/**
* Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
* serialization). This has been measured to save at least 400 bytes compared to regular
* serialization.
*
* <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
*/
public void writeTo(OutputStream out) throws IOException {
/*
* Serial form:
* 1 signed byte for the strategy
* 1 unsigned byte for the number of hash functions
* 1 big endian int, the number of longs in our bitset
* N big endian longs of our bitset
*/
DataOutputStream dout = new DataOutputStream(out);
dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
dout.writeInt(bits.data.length);
for (long value : bits.data) {
dout.writeLong(value);
}
}
示例4: DoubleLexicoderTest
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
public DoubleLexicoderTest() {
super(
Lexicoders.DOUBLE,
Double.MIN_VALUE,
Double.MAX_VALUE,
new Double[] {
-10d,
Double.MIN_VALUE,
11d,
-14.2,
14.2,
-100.002,
100.002,
-11d,
Double.MAX_VALUE,
0d
},
SignedBytes.lexicographicalComparator());
}
示例5: compareBytes
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
/** Compare two byte arrays by lexicographical order. */
public static int compareBytes(byte[] left, byte[] right) {
if (left == null) {
left = EMPTY_BYTES;
}
if (right == null) {
right = EMPTY_BYTES;
}
return SignedBytes.lexicographicalComparator().compare(left, right);
}
示例6: writeTo
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
/**
* Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
* serialization). This has been measured to save at least 400 bytes compared to regular
* serialization.
*
* <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
*/
public void writeTo(OutputStream out) throws IOException {
// Serial form:
// 1 signed byte for the strategy
// 1 unsigned byte for the number of hash functions
// 1 big endian int, the number of longs in our bitset
// N big endian longs of our bitset
DataOutputStream dout = new DataOutputStream(out);
dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
dout.writeInt(bits.data.length);
for (long value : bits.data) {
dout.writeLong(value);
}
}
示例7: compare
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
@Override
public int compare(ABICallSpec specA, ABICallSpec specB) {
return SignedBytes.lexicographicalComparator().compare(
specA.getEncoded(),
specB.getEncoded()
);
}
示例8: compare
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
@Override
public int compare(INode left, INode right) {
if (left == null) {
return right == null ? 0 : -1;
} else {
if (right == null) {
return 1;
} else {
int cmp = compare(left.getParent(), right.getParent());
return cmp == 0 ? SignedBytes.lexicographicalComparator().compare(
left.getLocalNameBytes(), right.getLocalNameBytes()) : cmp;
}
}
}
示例9: writeTo
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
/**
* Writes this cuckoo filter to an output stream, with a custom format (not Java serialization).
* This has been measured to save at least 400 bytes compared to regular serialization. <p/>
*
* Use {@link #readFrom(InputStream, Funnel)} to reconstruct the written CuckooFilter.
*/
public void writeTo(OutputStream out) throws IOException {
/*
* Serial form:
* 1 signed byte for the strategy
* 1 IEEE 754 floating-point double, the expected FPP
* 1 big endian long, the number of entries
* 1 big endian long, the checksum of entries
* 1 big endian long for the number of buckets
* 1 big endian int for the number of entries per bucket
* 1 big endian int for the fingerprint size in bits
* 1 big endian int, the number of longs in the filter table's data
* N big endian longs of the filter table's data
*/
DataOutputStream dout = new DataOutputStream(out);
dout.writeByte(SignedBytes.checkedCast(cuckooStrategy.ordinal()));
dout.writeDouble(fpp);
dout.writeLong(table.size());
dout.writeLong(table.checksum());
dout.writeLong(table.numBuckets());
dout.writeInt(table.numEntriesPerBucket());
dout.writeInt(table.numBitsPerEntry());
dout.writeInt(table.data().length);
for (long value : table.data()) {
dout.writeLong(value);
}
}
示例10: compare
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
@Override
public int compare(byte[] left, byte[] right) {
int minLength = Math.min(left.length, right.length);
for (int i = 0; i < minLength; i++) {
int result = SignedBytes.compare(left[i], right[i]);
if (result != 0) {
return result;
}
}
return left.length - right.length;
}
示例11: compareTo
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
@Override
public final int compareTo(INode other) {
String left = name == null ? "" : name;
String right = other.name == null ? "" : other.name;
return SignedBytes.lexicographicalComparator()
.compare(left.getBytes(), right.getBytes());
}
示例12: writeTo
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
/**
* Writes this {@code BloomFilter} to an output stream, with a custom format (not Java
* serialization). This has been measured to save at least 400 bytes compared to regular
* serialization.
*
* <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter.
*/
public void writeTo(OutputStream out) throws IOException {
// Serial form:
// 1 signed byte for the strategy
// 1 unsigned byte for the number of hash functions
// 1 big endian int, the number of longs in our bitset
// N big endian longs of our bitset
DataOutputStream dout = new DataOutputStream(out);
dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
dout.writeInt(bits.data.length());
for (int i = 0; i < bits.data.length(); i++) {
dout.writeLong(bits.data.get(i));
}
}
示例13: compareTo
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
@Override
public int compareTo(
final PartitionDataWritable o ) {
final int val = SignedBytes.lexicographicalComparator().compare(
partitionData.getId().getBytes(),
o.partitionData.getId().getBytes());
if ((val == 0) && (o.partitionData.getGroupId() != null) && (partitionData.getGroupId() != null)) {
return SignedBytes.lexicographicalComparator().compare(
partitionData.getGroupId().getBytes(),
o.partitionData.getGroupId().getBytes());
}
return val;
}
示例14: testGetId_2DSpatialLexicographicOrdering
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
@Test
public void testGetId_2DSpatialLexicographicOrdering()
throws Exception {
final int LATITUDE_BITS = 31;
final int LONGITUDE_BITS = 31;
final double[] minValue = new double[] {
-90,
-180
};
final double[] maxValue = new double[] {
90,
180
};
final SFCDimensionDefinition[] SPATIAL_DIMENSIONS = new SFCDimensionDefinition[] {
new SFCDimensionDefinition(
new LatitudeDefinition(),
LATITUDE_BITS),
new SFCDimensionDefinition(
new LongitudeDefinition(),
LONGITUDE_BITS)
};
final SpaceFillingCurve hilbertSFC = SFCFactory.createSpaceFillingCurve(
SPATIAL_DIMENSIONS,
SFCType.HILBERT);
Assert.assertTrue(SignedBytes.lexicographicalComparator().compare(
hilbertSFC.getId(minValue),
hilbertSFC.getId(maxValue)) < 0);
}
示例15: compare
import com.google.common.primitives.SignedBytes; //导入依赖的package包/类
@Override
public int compare(final byte[] o1, final byte[] o2) {
final Comparator<byte[]> c = SignedBytes.lexicographicalComparator();
return c.compare(o1, o2);
}