java.util.BitSet.size()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中java.util.BitSet.size()方法的一些代码示例,展示了BitSet.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.size()方法的具体详情如下:
包路径:java.util.BitSet
类名称:BitSet
方法名:size

BitSet.size介绍

[英]Returns the capacity in bits of the array implementing this BitSet. This is unrelated to the length of the BitSet, and not generally useful. Use #nextSetBit to iterate, or #length to find the highest set bit.
[中]返回实现此位集的数组的容量(以位为单位)。这与位集的长度无关,通常不有用。使用#nextSetBit进行迭代,或使用#length查找最高的集合位。

代码示例

代码示例来源:origin: apache/incubator-druid

  1. @Override
  2. public int getSizeInBytes()
  3. {
  4. // BitSet.size() returns the size in *bits*
  5. return this.bitmap.size() / Byte.SIZE;
  6. }

代码示例来源:origin: google/guava

  1. private BitSetMatcher(BitSet table, String description) {
  2. super(description);
  3. if (table.length() + Long.SIZE < table.size()) {
  4. table = (BitSet) table.clone();
  5. // If only we could actually call BitSet.trimToSize() ourselves...
  6. }
  7. this.table = table;
  8. }

代码示例来源:origin: addthis/stream-lib

  1. public int buckets() {
  2. return filter_.size();
  3. }

代码示例来源:origin: prestodb/presto

  1. private BitSetMatcher(BitSet table, String description) {
  2. super(description);
  3. if (table.length() + Long.SIZE < table.size()) {
  4. table = (BitSet) table.clone();
  5. // If only we could actually call BitSet.trimToSize() ourselves...
  6. }
  7. this.table = table;
  8. }

代码示例来源:origin: commons-collections/commons-collections

  1. /**
  2. * Returns <code>true</code> iff any bit in the given set is
  3. * <code>true</code>.
  4. */
  5. private boolean anyValueSet(BitSet set) {
  6. for (int i = 0; i < set.size(); i++) {
  7. if (set.get(i)) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

代码示例来源:origin: google/j2objc

  1. private BitSetMatcher(BitSet table, String description) {
  2. super(description);
  3. if (table.length() + Long.SIZE < table.size()) {
  4. table = (BitSet) table.clone();
  5. // If only we could actually call BitSet.trimToSize() ourselves...
  6. }
  7. this.table = table;
  8. }

代码示例来源:origin: hibernate/hibernate-orm

  1. private boolean isGeometryArgument(int idx) {
  2. return this.argumentIsGeometryTypeMask.size() > idx && this.argumentIsGeometryTypeMask.get( idx );
  3. }

代码示例来源:origin: wildfly/wildfly

  1. /**
  2. * Returns <code>true</code> iff any bit in the given set is
  3. * <code>true</code>.
  4. */
  5. private boolean anyValueSet(BitSet set) {
  6. for (int i = 0; i < set.size(); i++) {
  7. if (set.get(i)) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

代码示例来源:origin: apache/hive

  1. static boolean needsEscaping(char c) {
  2. return c >= 0 && c < charToEscape.size() && charToEscape.get(c);
  3. }

代码示例来源:origin: apache/hive

  1. private static boolean needsEscaping(char c) {
  2. return c >= 0 && c < charToEscape.size() && charToEscape.get(c);
  3. }

代码示例来源:origin: org.apache.commons/commons-collections4

  1. /**
  2. * Returns <code>true</code> iff any bit in the given set is
  3. * <code>true</code>.
  4. */
  5. private boolean anyValueSet(final BitSet set) {
  6. for (int i = 0; i < set.size(); i++) {
  7. if (set.get(i)) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

代码示例来源:origin: wildfly/wildfly

  1. private BitSetMatcher(BitSet table, String description) {
  2. super(description);
  3. if (table.length() + Long.SIZE < table.size()) {
  4. table = (BitSet) table.clone();
  5. // If only we could actually call BitSet.trimToSize() ourselves...
  6. }
  7. this.table = table;
  8. }

代码示例来源:origin: apache/ignite

  1. /** {@inheritDoc} */
  2. @Override public boolean connectionAvailable(ClusterNode node1, ClusterNode node2) {
  3. BitSet nodeState = nodesState.get(node1.id());
  4. if (nodeState == null)
  5. throw new IllegalArgumentException("Invalid node: " + node1);
  6. int nodeIdx = Collections.binarySearch(initialNodes, node2, NODE_ORDER_CMP);
  7. if (nodeIdx < 0)
  8. throw new IllegalArgumentException("Invalid node: " + node2);
  9. assert nodeIdx < nodeState.size() : nodeIdx;
  10. return nodeState.get(nodeIdx);
  11. }

代码示例来源:origin: Codecademy/EventHub

  1. public boolean isPresent(String key) {
  2. for (int bucketIndex : getHashBuckets(key.getBytes(), hashCount, bitSet.size())) {
  3. if (!bitSet.get(bucketIndex)) {
  4. return false;
  5. }
  6. }
  7. return true;
  8. }

代码示例来源:origin: Codecademy/EventHub

  1. public void add(String key) {
  2. for (int bucketIndex : getHashBuckets(key.getBytes(), hashCount, bitSet.size())) {
  3. bitSet.set(bucketIndex);
  4. }
  5. }

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. protected void write(BitSet value) throws IOException {
  2. if (value == null) {
  3. write(NULL_OBJECT);
  4. return;
  5. }
  6. write(value.size());
  7. // TODO: MAKE THIS SMALLER
  8. for (int x = 0, max = value.size(); x < max; x++)
  9. write(value.get(x));
  10. }

代码示例来源:origin: com.h2database/h2

  1. /**
  2. * Get the position of the last (infinite) free space.
  3. *
  4. * @return the position.
  5. */
  6. public long getLastFree() {
  7. return getPos(set.previousSetBit(set.size()-1) + 1);
  8. }

代码示例来源:origin: OryxProject/oryx

  1. @Override
  2. public boolean isPositive(Example example) {
  3. CategoricalFeature feature = (CategoricalFeature) example.getFeature(getFeatureNumber());
  4. if (feature == null) {
  5. return defaultDecision;
  6. }
  7. int encoding = feature.getEncoding();
  8. if (encoding >= activeCategoryEncodings.size()) {
  9. return defaultDecision;
  10. }
  11. return activeCategoryEncodings.get(encoding);
  12. }

代码示例来源:origin: mabe02/lanterna

  1. void setDirty(TerminalPosition position) {
  2. if(position.getRow() < firstRowIndex ||
  3. position.getRow() >= firstRowIndex + table.size()) {
  4. return;
  5. }
  6. BitSet tableRow = table.get(position.getRow() - firstRowIndex);
  7. if(position.getColumn() < tableRow.size()) {
  8. tableRow.set(position.getColumn());
  9. }
  10. }

代码示例来源:origin: apache/kylin

  1. @Test
  2. public void basicTest() {
  3. BitSet a = BitSets.valueOf(new int[] { 1, 3, 10 });
  4. Assert.assertEquals(3, a.cardinality());
  5. Assert.assertTrue(10 < a.size());
  6. Assert.assertTrue(a.get(3));
  7. }

相关文章