本文整理汇总了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;
}
示例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;
}
示例3: listHashCode
import java.util.Collection; //导入方法依赖的package包/类
private static int listHashCode(Collection<?> c) {
return c == null || c.isEmpty() ? 0 : c.hashCode();
}