本文整理汇总了Java中java.util.TreeSet.equals方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSet.equals方法的具体用法?Java TreeSet.equals怎么用?Java TreeSet.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.TreeSet
的用法示例。
在下文中一共展示了TreeSet.equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForAllExpectationsToBeSatisfied
import java.util.TreeSet; //导入方法依赖的package包/类
public boolean waitForAllExpectationsToBeSatisfied(int timeoutSeconds) {
// TODO(fischman): problems with this approach:
// - come up with something better than a poll loop
// - avoid serializing expectations explicitly; the test is not as robust
// as it could be because it must place expectations between wait
// statements very precisely (e.g. frame must not arrive before its
// expectation, and expectation must not be registered so early as to
// stall a wait). Use callbacks to fire off dependent steps instead of
// explicitly waiting, so there can be just a single wait at the end of
// the test.
long endTime = System.currentTimeMillis() + 1000 * timeoutSeconds;
TreeSet<String> prev = null;
TreeSet<String> stillWaitingForExpectations = unsatisfiedExpectations();
while (!stillWaitingForExpectations.isEmpty()) {
if (!stillWaitingForExpectations.equals(prev)) {
System.out.println(name + " still waiting at\n " + (new Throwable()).getStackTrace()[1]
+ "\n for: " + Arrays.toString(stillWaitingForExpectations.toArray()));
}
if (endTime < System.currentTimeMillis()) {
System.out.println(name + " timed out waiting for: "
+ Arrays.toString(stillWaitingForExpectations.toArray()));
return false;
}
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
prev = stillWaitingForExpectations;
stillWaitingForExpectations = unsatisfiedExpectations();
}
if (prev == null) {
System.out.println(
name + " didn't need to wait at\n " + (new Throwable()).getStackTrace()[1]);
}
return true;
}