org.bitcoinj.core.Utils.maxOfMostFreq()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(129)

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

Utils.maxOfMostFreq介绍

暂无

代码示例

代码示例来源:origin: greenaddress/GreenBits

public static int maxOfMostFreq(int... items) {
  // Java 6 sucks.
  ArrayList<Integer> list = new ArrayList<>(items.length);
  for (int item : items) list.add(item);
  return maxOfMostFreq(list);
}

代码示例来源:origin: HashEngineering/dashj

public static int maxOfMostFreq(int... items) {
  // Java 6 sucks.
  ArrayList<Integer> list = new ArrayList<Integer>(items.length);
  for (int item : items) list.add(item);
  return maxOfMostFreq(list);
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

public static int maxOfMostFreq(int... items) {
  // Java 6 sucks.
  ArrayList<Integer> list = new ArrayList<Integer>(items.length);
  for (int item : items) list.add(item);
  return maxOfMostFreq(list);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

public static int maxOfMostFreq(int... items) {
  // Java 6 sucks.
  ArrayList<Integer> list = new ArrayList<>(items.length);
  for (int item : items) list.add(item);
  return maxOfMostFreq(list);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Returns most commonly reported chain height from the given list of {@link Peer}s.
 * If multiple heights are tied, the highest is returned. If no peers are connected, returns zero.
 */
public static int getMostCommonChainHeight(final List<Peer> peers) {
  if (peers.isEmpty())
    return 0;
  List<Integer> heights = new ArrayList<>(peers.size());
  for (Peer peer : peers) heights.add((int) peer.getBestHeight());
  return Utils.maxOfMostFreq(heights);
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Returns most commonly reported chain height from the given list of {@link Peer}s.
 * If multiple heights are tied, the highest is returned. If no peers are connected, returns zero.
 */
public static int getMostCommonChainHeight(final List<Peer> peers) {
  if (peers.isEmpty())
    return 0;
  List<Integer> heights = new ArrayList<Integer>(peers.size());
  for (Peer peer : peers) heights.add((int) peer.getBestHeight());
  return Utils.maxOfMostFreq(heights);
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Returns most commonly reported chain height from the given list of {@link Peer}s.
 * If multiple heights are tied, the highest is returned. If no peers are connected, returns zero.
 */
public static int getMostCommonChainHeight(final List<Peer> peers) {
  if (peers.isEmpty())
    return 0;
  List<Integer> heights = new ArrayList<>(peers.size());
  for (Peer peer : peers) heights.add((int) peer.getBestHeight());
  return Utils.maxOfMostFreq(heights);
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Returns most commonly reported chain height from the given list of {@link Peer}s.
 * If multiple heights are tied, the highest is returned. If no peers are connected, returns zero.
 */
public static int getMostCommonChainHeight(final List<Peer> peers) {
  if (peers.isEmpty())
    return 0;
  List<Integer> heights = new ArrayList<Integer>(peers.size());
  for (Peer peer : peers) heights.add((int) peer.getBestHeight());
  return Utils.maxOfMostFreq(heights);
}

代码示例来源:origin: greenaddress/GreenBits

@Test
public void testMaxOfMostFreq() throws Exception {
  assertEquals(0, Utils.maxOfMostFreq());
  assertEquals(0, Utils.maxOfMostFreq(0, 0, 1));
  assertEquals(2, Utils.maxOfMostFreq(1, 1, 2, 2));
  assertEquals(1, Utils.maxOfMostFreq(1, 1, 2, 2, 1));
  assertEquals(-1, Utils.maxOfMostFreq(-1, -1, 2, 2, -1));
}

相关文章