本文整理匯總了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;
}