本文整理汇总了Java中java.util.ArrayDeque.clear方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayDeque.clear方法的具体用法?Java ArrayDeque.clear怎么用?Java ArrayDeque.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ArrayDeque
的用法示例。
在下文中一共展示了ArrayDeque.clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: trackNewWorkUnit
import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
* Store dependency tables for later retrieval by the EE.
* @param workunit
*/
void trackNewWorkUnit(final Map<Integer, List<VoltTable>> dependencies) {
for (final Entry<Integer, List<VoltTable>> e : dependencies.entrySet()) {
// could do this optionally - debug only.
if (debug.val) verifyDependencySanity(e.getKey(), e.getValue());
// create a new list of references to the workunit's table
// to avoid any changes to the WorkUnit's list. But do not
// copy the table data.
ArrayDeque<VoltTable> deque = m_depsById.get(e.getKey());
if (deque == null) {
deque = new ArrayDeque<VoltTable>();
// intentionally overwrite the previous dependency id.
// would a lookup and a clear() be faster?
m_depsById.put(e.getKey(), deque);
} else {
deque.clear();
}
for (VoltTable vt : e.getValue()) {
if (vt != null) deque.add(vt);
} // FOR
}
if (debug.val) LOG.debug("Current InputDepencies:\n" + StringUtil.formatMaps(m_depsById));
}
示例2: testClear
import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
* clear removes all elements
*/
public void testClear() {
ArrayDeque q = populatedDeque(SIZE);
q.clear();
assertTrue(q.isEmpty());
assertEquals(0, q.size());
assertTrue(q.add(new Integer(1)));
assertFalse(q.isEmpty());
q.clear();
assertTrue(q.isEmpty());
}
示例3: clear
import java.util.ArrayDeque; //导入方法依赖的package包/类
final synchronized void clear(ArrayDeque q) {
q.clear();
}