当前位置: 首页>>代码示例>>Java>>正文


Java SignedBytes类代码示例

本文整理汇总了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;
		}
	};
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:19,代码来源:TileEntityRenderDisplay.java

示例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);
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:24,代码来源:BloomFilter.java

示例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);
  }
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:24,代码来源:BloomFilter.java

示例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());
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:DoubleLexicoderTest.java

示例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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:NuCypherExtUtilClient.java

示例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);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:BloomFilter.java

示例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()
    );
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:8,代码来源:ABICallSpec.java

示例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;
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:SnapshotDiffInfo.java

示例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);
  }
}
 
开发者ID:bdupras,项目名称:guava-probably,代码行数:34,代码来源:CuckooFilter.java

示例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;
}
 
开发者ID:simonstey,项目名称:SecureLinkedData,代码行数:13,代码来源:IndexComparator.java

示例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());
}
 
开发者ID:hopshadoop,项目名称:hops-metadata-dal,代码行数:8,代码来源:INode.java

示例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));
  }
}
 
开发者ID:google,项目名称:guava,代码行数:22,代码来源:BloomFilter.java

示例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;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:14,代码来源:NNMapReduce.java

示例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);

}
 
开发者ID:locationtech,项目名称:geowave,代码行数:35,代码来源:HilbertSFCTest.java

示例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);
}
 
开发者ID:lmdbjava,项目名称:lmdbjava,代码行数:6,代码来源:ComparatorTest.java


注:本文中的com.google.common.primitives.SignedBytes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。