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


Java Collection.hashCode方法代碼示例

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


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

示例1: doPortfolio

import java.util.Collection; //導入方法依賴的package包/類
private int doPortfolio(String uid) {
  int rtn = 0;
  int initNQCount = localOpCount[OP_NQ];
  for (int i = 0; i < MAX_OP_ATTEMPTS[OP_P]; i++) {
    try {
      rtn = 0;
      if (VERBOSE) System.err.println("["+threadID+"] Getting portfolio for "+uid+"...");
      Collection holdingDataBeans = trade.getHoldings(uid);
      rtn += holdingDataBeans.hashCode();
      if (holdingDataBeans == null) {
        System.err.println("User "+uid+" has no holdings.");
      } else if (holdingDataBeans.size() > 0) {
        Iterator it = holdingDataBeans.iterator();
        HoldingDataBean holdingData = null;
        while (it.hasNext()) {
          holdingData = (HoldingDataBean) it.next();
          if (holdingData == null) {
            System.err.println("Collection contained null holding!");
          } else {
            rtn += doQuote(holdingData.getQuoteID(), true);
          }
        }
      }
      localOpCount[OP_P]++;
      return rtn;
    } catch (Exception e) {
      localOpCount[OP_NQ] = initNQCount;  // don't count aborted ops
      if (VERBOSE || i == MAX_OP_ATTEMPTS[OP_P] - 1) {
        System.err.println("Error getting portfolio for "+uid+": " + e.toString());
        e.printStackTrace();
      }
    }
  }
  return rtn;
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:36,代碼來源:DaCapoTrader.java

示例2: compareTo

import java.util.Collection; //導入方法依賴的package包/類
/**
 * Compare this Sequence to another node.<br><br>
 * 
 * A Sequence is always considered greater than a Scalar and less than
 * a Mapping.<br>
 * 
 * If o is a Sequence, their integer lengths are compared - the one with
 * the greater length is considered greater. If the lengths are equal,
 * then the 2 Sequences are equal if all elements are equal. If the
 * elements are not identical, the comparison of the first unequal
 * elements is returned.
 * 
 * @param other The other AbstractNode.
 * @checkstyle NestedIfDepth (100 lines)
 * @return
 *  a value < 0 if this < o <br>
 *   0 if this == o or <br>
 *  a value > 0 if this > o
 */
@Override
public int compareTo(final YamlNode other) {
    int result = 0;
    if (other == null || other instanceof Scalar) {
        result = 1;
    } else if (other instanceof YamlMapping) {
        result = -1;
    } else if (this != other) {
        final Collection<YamlNode> nodes = this.children();
        nodes.hashCode();
        final Collection<YamlNode> others = other.children();
        if(nodes.size() > others.size()) {
            result = 1;
        } else if (nodes.size() < others.size()) {
            result = -1;
        } else {
            final Iterator<YamlNode> ietrator = others.iterator();
            final Iterator<YamlNode> here = nodes.iterator();
            while(ietrator.hasNext()) {
                result = here.next().compareTo(ietrator.next());
                if(result != 0) {
                    break;
                }
            }
        }
    }
    return result;
}
 
開發者ID:decorators-squad,項目名稱:camel,代碼行數:48,代碼來源:AbstractYamlSequence.java

示例3: listHashCode

import java.util.Collection; //導入方法依賴的package包/類
private static int listHashCode(Collection<?> c) {
    return c == null || c.isEmpty() ? 0 : c.hashCode();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:CreateSymbols.java


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