当前位置: 首页>>代码示例>>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;未经允许,请勿转载。