本文整理汇总了Java中java.util.Deque.add方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.add方法的具体用法?Java Deque.add怎么用?Java Deque.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Deque
的用法示例。
在下文中一共展示了Deque.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enumerateAndMark
import java.util.Deque; //导入方法依赖的package包/类
/**
* Enumerates graph starting with provided vertexes. All vertexes that are reachable from the provided ones are
* marked
*
* @param markedParents provided vertexes
* @param markVertex lambda which marks vertexes
*/
public static void enumerateAndMark(Deque<Object[]> markedParents,
Consumer<Object[]> markVertex) {
Map<Object[], Boolean> isVisited = new HashMap<>();
while (!markedParents.isEmpty()) {
Object[] vertex = markedParents.pop();
if (vertex == null || isVisited.containsKey(vertex)) {
continue;
}
isVisited.put(vertex, true);
markVertex.accept(vertex);
for (int i = 0; i < vertex.length; ++i) {
if (vertex[i] == null) {
break;
}
markedParents.add((Object[]) vertex[i]);
}
}
}
示例2: getBinaryName
import java.util.Deque; //导入方法依赖的package包/类
private static String getBinaryName(Class<?> clz) {
StringBuilder sb = new StringBuilder();
sb.append(clz.getPackage().getName());
if (sb.length() > 0) {
sb.append('.'); //NOI18N
}
final Deque<Class<?>> clzs = new ArrayDeque<>();
for (; clz != null; clz = clz.getEnclosingClass()) {
clzs.add(clz);
}
while (!clzs.isEmpty()) {
sb.append(clzs.removeLast().getSimpleName());
if (!clzs.isEmpty()) {
sb.append('$'); //NOI18N
}
}
return sb.toString();
}
示例3: listChildrenBFSAndWatchThem
import java.util.Deque; //导入方法依赖的package包/类
/**
* BFS Traversal of all the children under path, with the entries in the list,
* in the same order as that of the traversal.
* Lists all the children and set watches on to them.
*
* @param zkw
* - zk reference
* @param znode
* - path of node
* @return list of children znodes under the path
* @throws KeeperException
* if unexpected ZooKeeper exception
*/
private static List<String> listChildrenBFSAndWatchThem(ZooKeeperWatcher zkw, final String znode)
throws KeeperException {
Deque<String> queue = new LinkedList<String>();
List<String> tree = new ArrayList<String>();
queue.add(znode);
while (true) {
String node = queue.pollFirst();
if (node == null) {
break;
}
List<String> children = listChildrenAndWatchThem(zkw, node);
if (children == null) {
continue;
}
for (final String child : children) {
final String childPath = node + "/" + child;
queue.add(childPath);
tree.add(childPath);
}
}
return tree;
}
示例4: walkFields
import java.util.Deque; //导入方法依赖的package包/类
private void walkFields(Deque stack, Object current, Class[] skip)
{
ClassInfo classInfo = getClassInfo(current.getClass(), skip);
for (Field field : classInfo._refFields)
{
try
{
Object value = field.get(current);
if (value == null || value.getClass().isPrimitive())
{
continue;
}
stack.add(value);
}
catch (IllegalAccessException ignored) { }
}
}
示例5: testPass
import java.util.Deque; //导入方法依赖的package包/类
@Test(timeout = 1000)
public void testPass() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.PASS);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.PASS);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.PASS, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verify(second).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例6: testPrepare
import java.util.Deque; //导入方法依赖的package包/类
@Test(timeout = 1000)
public void testPrepare() throws IOException {
And and = new And();
Expression first = mock(Expression.class);
Expression second = mock(Expression.class);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
and.prepare();
verify(first).prepare();
verify(second).prepare();
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例7: listChildrenBFSNoWatch
import java.util.Deque; //导入方法依赖的package包/类
/**
* BFS Traversal of all the children under path, with the entries in the list,
* in the same order as that of the traversal. Lists all the children without
* setting any watches.
*
* @param zkw
* - zk reference
* @param znode
* - path of node
* @return list of children znodes under the path
* @throws KeeperException
* if unexpected ZooKeeper exception
*/
private static List<String> listChildrenBFSNoWatch(ZooKeeperWatcher zkw,
final String znode) throws KeeperException {
Deque<String> queue = new LinkedList<String>();
List<String> tree = new ArrayList<String>();
queue.add(znode);
while (true) {
String node = queue.pollFirst();
if (node == null) {
break;
}
List<String> children = listChildrenNoWatch(zkw, node);
if (children == null) {
continue;
}
for (final String child : children) {
final String childPath = node + "/" + child;
queue.add(childPath);
tree.add(childPath);
}
}
return tree;
}
示例8: toStyleProcessorDistance
import java.util.Deque; //导入方法依赖的package包/类
@Test
public void toStyleProcessorDistance() {
final Deque<Object> contextData = new ArrayDeque<>();
final SlaData data = new SlaData();
data.setRevisedDueDateDistance(0L); // Perfect distance
contextData.add(data);
Assert.assertEquals("normal", resource.toStyleProcessorDistance("normal", "invalid").getValue(contextData));
}
示例9: addModelParentLocation
import java.util.Deque; //导入方法依赖的package包/类
private void addModelParentLocation(Deque<ResourceLocation> p_188633_1_, Set<ResourceLocation> p_188633_2_, ModelBlock p_188633_3_)
{
ResourceLocation resourcelocation = p_188633_3_.getParentLocation();
if (resourcelocation != null && !p_188633_2_.contains(resourcelocation))
{
p_188633_1_.add(resourcelocation);
}
}
示例10: toStyleProcessorDistanceLate
import java.util.Deque; //导入方法依赖的package包/类
@Test
public void toStyleProcessorDistanceLate() {
final Deque<Object> contextData = new ArrayDeque<>();
final SlaData data = new SlaData();
data.setRevisedDueDateDistance(-1L); // Negative distance, late
contextData.add(data);
Assert.assertEquals("invalid", resource.toStyleProcessorDistance("normal", "invalid").getValue(contextData));
}
示例11: getValue
import java.util.Deque; //导入方法依赖的package包/类
/**
* Simple test of a valid property.
*/
@Test
public void getValue() {
final Deque<Object> contextData = new LinkedList<>();
final SystemUser systemUser = new SystemUser();
systemUser.setLogin("any");
contextData.add(systemUser);
Assert.assertEquals("any", new BeanProcessor<>(SystemUser.class, "login").getValue(contextData));
}
示例12: getAllParentPaths
import java.util.Deque; //导入方法依赖的package包/类
private static Deque<String> getAllParentPaths(String baseDBPath) {
Deque<String> params = new ArrayDeque<String>();
Pattern compile = Pattern.compile("/[^/]*$");
String current = trimSuffix(baseDBPath, "/");
while( true ) {
current = compile.matcher(current).replaceFirst("");
if( current.isEmpty() ) {
break;
}
params.add(current+"/");
}
return params;
}
示例13: stringToDumpFileHistory
import java.util.Deque; //导入方法依赖的package包/类
public static Deque<File> stringToDumpFileHistory(String preference, boolean allowDirs) {
String[] coordStrings = preference.split(DbInfo.DELIM_ENTRY);
Deque<File> paths = new LinkedList<>();
for (String path : coordStrings){
File f = new File(path);
if (f.exists() && !paths.contains(f) && (allowDirs || !f.isDirectory())) {
paths.add(f);
}
}
return paths;
}
示例14: testGetWrappedValue
import java.util.Deque; //导入方法依赖的package包/类
/**
* Simple wrapping test of not null valued data.
*/
@Test
public void testGetWrappedValue() {
final SystemUser systemUser = new SystemUser();
systemUser.setLogin("any");
final SystemRoleAssignment roleAssignment = new SystemRoleAssignment();
roleAssignment.setUser(systemUser);
final Deque<Object> contextData = new LinkedList<>();
contextData.add(roleAssignment);
Assert.assertEquals("any",
new BeanProcessor<>(SystemUser.class, "login", new BeanProcessor<>(SystemRoleAssignment.class, "user")).getValue(contextData));
}
示例15: processBlock
import java.util.Deque; //导入方法依赖的package包/类
@SuppressWarnings("try")
private void processBlock(AbstractBlockBase<?> block, Deque<AbstractBlockBase<?>> worklist) {
DebugContext debug = lir.getDebug();
if (updateOutBlock(block)) {
try (Indent indent = debug.logAndIndent("handle block %s", block)) {
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
// get out set and mark intervals
BitSet outSet = liveOutMap.get(block);
markOutInterval(outSet, getBlockEnd(instructions));
printLiveSet("liveOut", outSet);
// process instructions
BlockClosure closure = new BlockClosure((BitSet) outSet.clone());
for (int i = instructions.size() - 1; i >= 0; i--) {
LIRInstruction inst = instructions.get(i);
closure.processInstructionBottomUp(inst);
}
// add predecessors to work list
for (AbstractBlockBase<?> b : block.getPredecessors()) {
worklist.add(b);
}
// set in set and mark intervals
BitSet inSet = closure.getCurrentSet();
liveInMap.put(block, inSet);
markInInterval(inSet, getBlockBegin(instructions));
printLiveSet("liveIn", inSet);
}
}
}