當前位置: 首頁>>代碼示例>>Java>>正文


Java CollectionUtils.size方法代碼示例

本文整理匯總了Java中org.apache.commons.collections4.CollectionUtils.size方法的典型用法代碼示例。如果您正苦於以下問題:Java CollectionUtils.size方法的具體用法?Java CollectionUtils.size怎麽用?Java CollectionUtils.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.collections4.CollectionUtils的用法示例。


在下文中一共展示了CollectionUtils.size方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createHeader

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
private BlockHeader createHeader(Block newBlockParent, List<BlockHeader> uncles, List<Transaction> txs, BigInteger minimumGasPrice) {
    final byte[] unclesListHash = HashUtil.sha3(BlockHeader.getUnclesEncodedEx(uncles));

    final long timestampSeconds = this.getCurrentTimeInSeconds();

    // Set gas limit before executing block
    BigInteger minGasLimit = BigInteger.valueOf(miningConfig.getGasLimit().getMininimum());
    BigInteger targetGasLimit = BigInteger.valueOf(miningConfig.getGasLimit().getTarget());
    BigInteger parentGasLimit = new BigInteger(1, newBlockParent.getGasLimit());
    BigInteger gasUsed = BigInteger.valueOf(newBlockParent.getGasUsed());
    boolean forceLimit = miningConfig.getGasLimit().isTargetForced();
    BigInteger gasLimit = gasLimitCalculator.calculateBlockGasLimit(parentGasLimit,
            gasUsed, minGasLimit, targetGasLimit, forceLimit);

    final BlockHeader newHeader = new BlockHeader(newBlockParent.getHash(),
            unclesListHash,
            coinbaseAddress,
            new Bloom().getData(),
            new byte[]{1},
            newBlockParent.getNumber() + 1,
            gasLimit.toByteArray(),
            0,
            timestampSeconds,
            new byte[]{},
            new byte[]{},
            new byte[]{},
            new byte[]{},
            minimumGasPrice.toByteArray(),
            CollectionUtils.size(uncles)
    );
    newHeader.setDifficulty(difficultyCalculator.calcDifficulty(newHeader, newBlockParent.getHeader()).toByteArray());
    newHeader.setTransactionsRoot(Block.getTxTrie(txs).getHash());
    return newHeader;
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:35,代碼來源:MinerServerImpl.java

示例2: getRandomizeLimitedList

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
private List<Node> getRandomizeLimitedList(List<Node> nodes, int maxNumber, int randomElements) {
    if (CollectionUtils.size(nodes) <= maxNumber) {
        return nodes;
    } else {
        List<Node> ret = new ArrayList<>();
        int limit = maxNumber - randomElements;
        ret.addAll(nodes.subList(0, limit - 1));
        ret.addAll(collectRandomNodes(nodes.subList(limit, nodes.size()), randomElements));

        return ret;
    }
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:13,代碼來源:PeerExplorer.java

示例3: getMessageContentInfo

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
public String getMessageContentInfo() {
    int size = CollectionUtils.size(this.transactions);
    StringBuilder sb = new StringBuilder(size).append(" Received.");

    if(size > 0) {
        sb.append(": ");
        this.getTransactions().forEach(tx -> sb.append(Hex.toHexString(tx.getHash())).append(", "));
    }

    return sb.toString();
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:12,代碼來源:TransactionsMessage.java

示例4: totalSize

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
/**
 * Gets the total size of the map by counting all the values.
 *
 * @return the total size of the map counting all values
 */
public int totalSize() {
    int total = 0;
    for (final Object v : decorated().values()) {
        total += CollectionUtils.size(v);
    }
    return total;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:13,代碼來源:MultiValueMap.java

示例5: checkNoStageEnvironment

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
/**
 * Checks that stage env does not exist yet.
 */
private void checkNoStageEnvironment()
{
  Environment stageEnv = environmentTx.findNamedEnvAllowNull(stageEnvName);
  if (stageEnv != null)
  {
    throw new IllegalStateException(stageContext() + "Stage env exists already, with "
        + CollectionUtils.size(stageEnv.getLogicalDatabases()) + " logical databases ["
        + environmentHelper.listOfNames(stageEnv.getLogicalDatabases())
        + "], you must manually destroy the stage env and run this job again");
  }
}
 
開發者ID:Nike-Inc,項目名稱:bluegreen-manager,代碼行數:15,代碼來源:RdsSnapshotRestoreTask.java

示例6: countNodes

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
public int countNodes() {
    return CollectionUtils.size(this.nodes);
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:4,代碼來源:NeighborsPeerMessage.java

示例7: createChildBlock

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
public Block createChildBlock(Block parent, List<Transaction> txs, List<BlockHeader> uncles,
                              long difficulty, BigInteger minGasPrice, byte[] gasLimit) {
    if (txs == null) {
        txs = new ArrayList<>();
    }

    if (uncles == null) {
        uncles = new ArrayList<>();
    }

    byte[] unclesListHash = HashUtil.sha3(BlockHeader.getUnclesEncodedEx(uncles));

    BlockHeader newHeader = new BlockHeader(parent.getHash(),
            unclesListHash,
            parent.getCoinbase(),
            ByteUtils.clone(new Bloom().getData()),
            new byte[]{1},
            parent.getNumber()+1,
            gasLimit,
            0,
            parent.getTimestamp() + ++count,
            new byte[]{},
            new byte[]{},
            new byte[]{},
            new byte[]{},
            (minGasPrice != null) ? minGasPrice.toByteArray() : null,
            CollectionUtils.size(uncles)
    );

    if (difficulty == 0) {
        newHeader.setDifficulty(difficultyCalculator.calcDifficulty(newHeader, parent.getHeader()).toByteArray());
    }
    else {
        newHeader.setDifficulty(BigInteger.valueOf(difficulty).toByteArray());
    }

    newHeader.setTransactionsRoot(Block.getTxTrie(txs).getHash());

    newHeader.setStateRoot(ByteUtils.clone(parent.getStateRoot()));

    Block newBlock = new Block(newHeader, txs, uncles);

    return newBlock;
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:45,代碼來源:BlockGenerator.java


注:本文中的org.apache.commons.collections4.CollectionUtils.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。