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


Java NavigableSet.size方法代码示例

本文整理汇总了Java中java.util.NavigableSet.size方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableSet.size方法的具体用法?Java NavigableSet.size怎么用?Java NavigableSet.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.NavigableSet的用法示例。


在下文中一共展示了NavigableSet.size方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mutateSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSet(NavigableSet<Integer> set, int min, int max) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min + rnd.nextInt(rangeSize);
        assertTrue(element >= min && element <= max);
        put(set, element);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:TreeSetTest.java

示例2: mutateSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSet(NavigableSet<Integer> set, int min, int max, BitSet bs) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10), bs);
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min + rnd.nextInt(rangeSize);
        assertTrue(element >= min && element <= max);
        put(set, element, bs);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ConcurrentSkipListSetTest.java

示例3: getOrderedPrices

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Get an ordered array of prices
 *
 * @param ascending when true, values are sorted in ascending order,
 * descending otherwise
 * @return n-th highest order or null if index out of bounds
 */
public Decimal[] getOrderedPrices(boolean ascending) {
    NavigableSet<Decimal> ns = ascending ? orders.navigableKeySet()
            : orders.descendingKeySet();
    Decimal[] prices = new Decimal[ns.size()];
    ns.toArray(prices);
    return prices;
}
 
开发者ID:prog-fun,项目名称:exchange-apis,代码行数:15,代码来源:Book.java

示例4: transformedNavigableSet

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Factory method to create a transforming navigable set that will transform
 * existing contents of the specified navigable set.
 * <p>
 * If there are any elements already in the set being decorated, they
 * will be transformed by this method.
 * Contrast this with {@link #transformingNavigableSet(NavigableSet, Transformer)}.
 *
 * @param <E> the element type
 * @param set  the set to decorate, must not be null
 * @param transformer  the transformer to use for conversion, must not be null
 * @return a new transformed {@link NavigableSet}
 * @throws NullPointerException if set or transformer is null
 */
public static <E> TransformedNavigableSet<E> transformedNavigableSet(final NavigableSet<E> set,
        final Transformer<? super E, ? extends E> transformer) {

    final TransformedNavigableSet<E> decorated = new TransformedNavigableSet<E>(set, transformer);
    if (set.size() > 0) {
        @SuppressWarnings("unchecked") // set is type E
        final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics
        set.clear();
        for (final E value : values) {
            decorated.decorated().add(transformer.transform(value));
        }
    }
    return decorated;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:29,代码来源:TransformedNavigableSet.java

示例5: mutateSubSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSubSet(NavigableSet<Integer> set, int min, int max) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min - 5 + rnd.nextInt(rangeSize + 10);
        if (element >= min && element <= max) {
            put(set, element);
        } else {
            try {
                set.add(element);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TreeSetTest.java

示例6: mutateSubSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSubSet(NavigableSet<Integer> set, int min, int max,
                  BitSet bs) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10), bs);
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min - 5 + rnd.nextInt(rangeSize + 10);
        if (element >= min && element <= max) {
            put(set, element, bs);
        } else {
            try {
                set.add(element);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:ConcurrentSkipListSetTest.java

示例7: visitRegionRecoveredEdits

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Iterate over recovered.edits of the specified region
 *
 * @param fs {@link FileSystem}
 * @param regionDir {@link Path} to the Region directory
 * @param visitor callback object to get the recovered.edits files
 * @throws IOException if an error occurred while scanning the directory
 */
public static void visitRegionRecoveredEdits(final FileSystem fs, final Path regionDir,
    final FSVisitor.RecoveredEditsVisitor visitor) throws IOException {
  NavigableSet<Path> files = WALSplitter.getSplitEditFilesSorted(fs, regionDir);
  if (files == null || files.size() == 0) return;

  for (Path source: files) {
    // check to see if the file is zero length, in which case we can skip it
    FileStatus stat = fs.getFileStatus(source);
    if (stat.getLen() <= 0) continue;

    visitor.recoveredEdits(regionDir.getName(), source.getName());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:FSVisitor.java

示例8: StoreScanner

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * An internal constructor.
 */
protected StoreScanner(Store store, Scan scan, final ScanInfo scanInfo,
    final NavigableSet<byte[]> columns, long readPt, boolean cacheBlocks) {
  this.readPt = readPt;
  this.store = store;
  this.cacheBlocks = cacheBlocks;
  get = scan.isGetScan();
  int numCol = columns == null ? 0 : columns.size();
  explicitColumnQuery = numCol > 0;
  this.scan = scan;
  this.columns = columns;
  this.now = EnvironmentEdgeManager.currentTime();
  this.oldestUnexpiredTS = now - scanInfo.getTtl();
  this.minVersions = scanInfo.getMinVersions();

  // We look up row-column Bloom filters for multi-column queries as part of
  // the seek operation. However, we also look the row-column Bloom filter
  // for multi-row (non-"get") scans because this is not done in
  // StoreFile.passesBloomFilter(Scan, SortedSet<byte[]>).
  this.useRowColBloom = numCol > 1 || (!get && numCol == 1);

  this.maxRowSize = scanInfo.getTableMaxRowSize();
  this.scanUsePread = scan.isSmall() ? true : scanInfo.isUsePread();
  this.cellsPerHeartbeatCheck = scanInfo.getCellsPerTimeoutCheck();
  // Parallel seeking is on if the config allows and more there is more than one store file.
  if (this.store != null && this.store.getStorefilesCount() > 1) {
    RegionServerServices rsService = ((HStore) store).getHRegion().getRegionServerServices();
    if (rsService != null && scanInfo.isParallelSeekEnabled()) {
      this.parallelSeekEnabled = true;
      this.executor = rsService.getExecutorService();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:StoreScanner.java

示例9: ExplicitColumnTracker

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Default constructor.
 * @param columns columns specified user in query
 * @param minVersions minimum number of versions to keep
 * @param maxVersions maximum versions to return per column
 * @param oldestUnexpiredTS the oldest timestamp we are interested in,
 *  based on TTL 
 */
public ExplicitColumnTracker(NavigableSet<byte[]> columns, int minVersions,
    int maxVersions, long oldestUnexpiredTS) {
  this.maxVersions = maxVersions;
  this.minVersions = minVersions;
  this.oldestStamp = oldestUnexpiredTS;
  this.columns = new ColumnCount[columns.size()];
  int i=0;
  for(byte [] column : columns) {
    this.columns[i++] = new ColumnCount(column);
  }
  reset();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:ExplicitColumnTracker.java

示例10: buildDtoChanges

import java.util.NavigableSet; //导入方法依赖的package包/类
public DtoChanges buildDtoChanges(
    final TransactionId.W lowerTxid,
    final boolean lowerInclusive,
    final TransactionId.W upperTxid,
    final boolean upperInclusive)
{
    final Set<AbstractModel> newMvos = new HashSet<AbstractModel>();
    final Set<AbstractModel> changedMvos = new HashSet<AbstractModel>();
    for (AbstractModel obj : getAbstractModels()) {
        final TransactionId.W initialTxid = obj.getInitialVersion();
        if (lowerTxid.serial <= initialTxid.serial && initialTxid.serial <= upperTxid.serial) {
            newMvos.add(obj);
        }
        NavigableSet<TransactionId.W> txids = new TreeSet<TransactionId.W>();
        txids.addAll(getTransactionIds(obj));

        for (String attrname : obj.getAttributeNames()) {
            final Object value = obj.getValue(attrname);
            if (value instanceof Attribute.SetAttr<?, ?>) {
                final MvoSet<?> mvoset = ((Attribute.SetAttr<?, AbstractModel>) value).get(obj);
                txids.addAll(getTransactionIds(mvoset));
            }
            if (value instanceof Attribute.ListAttr<?, ?>) {
                final MvoList<?> mvolist = ((Attribute.ListAttr<?, AbstractModel>) value).get(obj);
                txids.addAll(getTransactionIds(mvolist));
            }
            if (value instanceof Attribute.MapAttr<?, ?, ?>) {
                final MvoMap<?, ?> mvomap = ((Attribute.MapAttr<?, ?, AbstractModel>) value).get(obj);
                txids.addAll(getTransactionIds(mvomap));
            }
        }

        txids = txids.subSet(lowerTxid, lowerInclusive, upperTxid, upperInclusive);

        if (0 < txids.size()) {
            changedMvos.add(obj);
        }
    }
    changedMvos.removeAll(newMvos);

    return new DtoChanges(
        originator_, lowerTxid, upperTxid, TransactionContext.getTargetTime(),
        buildDtos(newMvos), buildDtos(changedMvos));
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:45,代码来源:DtoChangesBuilder.java

示例11: ScanQueryMatcher

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Construct a QueryMatcher for a scan
 * @param scan
 * @param scanInfo The store's immutable scan info
 * @param columns
 * @param scanType Type of the scan
 * @param earliestPutTs Earliest put seen in any of the store files.
 * @param oldestUnexpiredTS the oldest timestamp we are interested in,
 *  based on TTL
 * @param regionCoprocessorHost 
 * @throws IOException 
 */
public ScanQueryMatcher(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> columns,
    ScanType scanType, long readPointToUse, long earliestPutTs, long oldestUnexpiredTS,
    long now, RegionCoprocessorHost regionCoprocessorHost) throws IOException {
  TimeRange timeRange = scan.getColumnFamilyTimeRange().get(scanInfo.getFamily());
  if (timeRange == null) {
    this.tr = scan.getTimeRange();
  } else {
    this.tr = timeRange;
  }
  this.rowComparator = scanInfo.getComparator();
  this.regionCoprocessorHost = regionCoprocessorHost;
  this.deletes =  instantiateDeleteTracker();
  this.stopRow = scan.getStopRow();
  this.startKey = KeyValueUtil.createFirstDeleteFamilyOnRow(scan.getStartRow(),
      scanInfo.getFamily());
  this.filter = scan.getFilter();
  this.earliestPutTs = earliestPutTs;
  this.oldestUnexpiredTS = oldestUnexpiredTS;
  this.now = now;

  this.maxReadPointToTrackVersions = readPointToUse;
  this.timeToPurgeDeletes = scanInfo.getTimeToPurgeDeletes();
  this.ttl = oldestUnexpiredTS;

  /* how to deal with deletes */
  this.isUserScan = scanType == ScanType.USER_SCAN;
  // keep deleted cells: if compaction or raw scan
  this.keepDeletedCells = scan.isRaw() ? KeepDeletedCells.TRUE :
    isUserScan ? KeepDeletedCells.FALSE : scanInfo.getKeepDeletedCells();
  // retain deletes: if minor compaction or raw scanisDone
  this.retainDeletesInOutput = scanType == ScanType.COMPACT_RETAIN_DELETES || scan.isRaw();
  // seePastDeleteMarker: user initiated scans
  this.seePastDeleteMarkers =
      scanInfo.getKeepDeletedCells() != KeepDeletedCells.FALSE && isUserScan;

  int maxVersions =
      scan.isRaw() ? scan.getMaxVersions() : Math.min(scan.getMaxVersions(),
        scanInfo.getMaxVersions());

  // Single branch to deal with two types of reads (columns vs all in family)
  if (columns == null || columns.size() == 0) {
    // there is always a null column in the wildcard column query.
    hasNullColumn = true;

    // use a specialized scan for wildcard column tracker.
    this.columns = new ScanWildcardColumnTracker(
        scanInfo.getMinVersions(), maxVersions, oldestUnexpiredTS);
  } else {
    // whether there is null column in the explicit column query
    hasNullColumn = (columns.first().length == 0);

    // We can share the ExplicitColumnTracker, diff is we reset
    // between rows, not between storefiles.
    this.columns = new ExplicitColumnTracker(columns, scanInfo.getMinVersions(), maxVersions,
        oldestUnexpiredTS);
  }
  this.isReversed = scan.isReversed();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:71,代码来源:ScanQueryMatcher.java

示例12: toGet

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Create a protocol buffer Get based on a client Get.
 *
 * @param get the client Get
 * @return a protocol buffer Get
 * @throws IOException
 */
public static ClientProtos.Get toGet(
    final Get get) throws IOException {
  ClientProtos.Get.Builder builder =
    ClientProtos.Get.newBuilder();
  builder.setRow(ByteStringer.wrap(get.getRow()));
  builder.setCacheBlocks(get.getCacheBlocks());
  builder.setMaxVersions(get.getMaxVersions());
  if (get.getFilter() != null) {
    builder.setFilter(ProtobufUtil.toFilter(get.getFilter()));
  }
  for (Entry<byte[], TimeRange> cftr : get.getColumnFamilyTimeRange().entrySet()) {
    HBaseProtos.ColumnFamilyTimeRange.Builder b = HBaseProtos.ColumnFamilyTimeRange.newBuilder();
    b.setColumnFamily(ByteString.copyFrom(cftr.getKey()));
    b.setTimeRange(timeRangeToProto(cftr.getValue()));
    builder.addCfTimeRange(b);
  }
  TimeRange timeRange = get.getTimeRange();
  if (!timeRange.isAllTime()) {
    HBaseProtos.TimeRange.Builder timeRangeBuilder =
      HBaseProtos.TimeRange.newBuilder();
    timeRangeBuilder.setFrom(timeRange.getMin());
    timeRangeBuilder.setTo(timeRange.getMax());
    builder.setTimeRange(timeRangeBuilder.build());
  }
  Map<String, byte[]> attributes = get.getAttributesMap();
  if (!attributes.isEmpty()) {
    NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
    for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
      attributeBuilder.setName(attribute.getKey());
      attributeBuilder.setValue(ByteStringer.wrap(attribute.getValue()));
      builder.addAttribute(attributeBuilder.build());
    }
  }
  if (get.hasFamilies()) {
    Column.Builder columnBuilder = Column.newBuilder();
    Map<byte[], NavigableSet<byte[]>> families = get.getFamilyMap();
    for (Map.Entry<byte[], NavigableSet<byte[]>> family: families.entrySet()) {
      NavigableSet<byte[]> qualifiers = family.getValue();
      columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
      columnBuilder.clearQualifier();
      if (qualifiers != null && qualifiers.size() > 0) {
        for (byte[] qualifier: qualifiers) {
          columnBuilder.addQualifier(ByteStringer.wrap(qualifier));
        }
      }
      builder.addColumn(columnBuilder.build());
    }
  }
  if (get.getMaxResultsPerColumnFamily() >= 0) {
    builder.setStoreLimit(get.getMaxResultsPerColumnFamily());
  }
  if (get.getRowOffsetPerColumnFamily() > 0) {
    builder.setStoreOffset(get.getRowOffsetPerColumnFamily());
  }
  if (get.isCheckExistenceOnly()){
    builder.setExistenceOnly(true);
  }
  if (get.isClosestRowBefore()){
    builder.setClosestRowBefore(true);
  }
  if (get.getConsistency() != null && get.getConsistency() != Consistency.STRONG) {
    builder.setConsistency(toConsistency(get.getConsistency()));
  }

  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:74,代码来源:ProtobufUtil.java


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