当前位置: 首页>>代码示例>>Java>>正文


Java LinkedList.pollFirst方法代码示例

本文整理汇总了Java中java.util.LinkedList.pollFirst方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedList.pollFirst方法的具体用法?Java LinkedList.pollFirst怎么用?Java LinkedList.pollFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.LinkedList的用法示例。


在下文中一共展示了LinkedList.pollFirst方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get_all_children

import java.util.LinkedList; //导入方法依赖的package包/类
public static Set<Long> get_all_children(Joern_db joern_db, Long node_id)
{
Set<Long> children = new HashSet<>();
LinkedList<Long> new_nodes = new LinkedList<>();
 new_nodes.add(node_id);
  while(!new_nodes.isEmpty())
   {
   Long cur = new_nodes.pollFirst();
   List<Node> its_children = Pipeline.v(cur).children().to_list();
     for(Node c : its_children)
      {
        if(children.contains(c.getId()))
         {
          continue;
         }
        new_nodes.add(c.getId());
        children.add(c.getId());
      }
   }
 return children;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:22,代码来源:Function_sets_parameter.java

示例2: doWhisper

import java.util.LinkedList; //导入方法依赖的package包/类
private void doWhisper(ConsoleInputEvent event) {
  LinkedList<String> list = new LinkedList<>(event.getInputSplit());

  if (list.isEmpty()) {
    return;
  }

  if (list.size() < 2) {
    logger.error("Whispering empty messages is not allowed");
    return;
  }

  String username = list.pollFirst();
  String message = list.stream().reduce((l, r) -> l + r).orElse("");
  chat.whisper(username, message);
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:17,代码来源:CliCommandRouter.java

示例3: transferThroughList

import java.util.LinkedList; //导入方法依赖的package包/类
private String transferThroughList(String in, int index) {
    LinkedList<String> list = new LinkedList<String>();
    list.add(System.getenv("")); // taints the list
    list.clear(); // makes the list safe again
    list.add(1, "xx");
    list.addFirst(in); // can taint the list
    list.addLast("yy");
    list.push(in);
    return list.element() + list.get(index) + list.getFirst() + list.getLast()
            + list.peek() + list.peekFirst() + list.peekLast() + list.poll()
            + list.pollFirst() + list.pollLast() + list.pop() + list.remove()
            + list.remove(index) + list.removeFirst() + list.removeLast()
            + list.set(index, "safe") + list.toString();
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:15,代码来源:CommandInjection.java

示例4: cacheAncestors

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Does a 'breadth first' search of ancestors, caching as it goes
 * @param nodeIds initial list of nodes to visit
 * @return all visited nodes, in no particular order
 */
private List<Long> cacheAncestors(List<Long> nodeIds)
{
    final LinkedList<Long> toVisit = new LinkedList<Long>(nodeIds);
    Set<Long> visited = new TreeSet<Long>();
    Long nodeId;
    nodeDAO.cacheNodesById(toVisit);
    Long lastCached = toVisit.peekLast();
    while ((nodeId = toVisit.pollFirst()) != null)
    {
        if (visited.add(nodeId) && (nodeDAO.getNodeIdStatus(nodeId) != null) && (false == nodeDAO.getNodeIdStatus(nodeId).isDeleted()))
        {
            nodeDAO.getParentAssocs(nodeId, null, null, null, new ChildAssocRefQueryCallback()
            {
                @Override
                public boolean preLoadNodes()
                {
                    return false;
                }

                @Override
                public boolean orderResults()
                {
                    return false;
                }

                @Override
                public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair,
                        Pair<Long, NodeRef> parentNodePair, Pair<Long, NodeRef> childNodePair)
                {
                    toVisit.add(parentNodePair.getFirst());
                    return true;
                }

                @Override
                public void done()
                {
                }
            });
        }
        final boolean nodeIdEqualsLastCached = (nodeId == null && lastCached == null) ||
                                               (nodeId != null && nodeId.equals(lastCached));
        if (nodeIdEqualsLastCached && !toVisit.isEmpty())
        {
            nodeDAO.cacheNodesById(toVisit);
            lastCached = toVisit.peekLast();
        }
    }
    return new ArrayList<Long>(visited);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:55,代码来源:SOLRTrackingComponentImpl.java

示例5: setPropertyDescriptor

import java.util.LinkedList; //导入方法依赖的package包/类
public void setPropertyDescriptor(AbstractCouchDbTransaction couchDbTransaction, PropertyDescriptor[] propertyDescriptors, DatabaseObject parentObject) {	
	cleanGroups();
	
	/* Fill the Group widget */
	for (PropertyDescriptor property : propertyDescriptors) {
		final String name = property.getName();
		final String description = property.getShortDescription();
		if (!parametersCouch.contains(name) ){

			if ( (name.startsWith("q_") || name.startsWith("p_")) ) {
				if (!parentObject.getClass().getCanonicalName().equals(property.getValue( 
							MySimpleBeanInfo.BLACK_LIST_PARENT_CLASS))) {
					Group choosenGroup = name.startsWith("q_") ? groupQueries : groupParameters;
					addToComposite(choosenGroup, name, description, false);
				}
			} 
		}
	}
	
	if (groupQueries.getChildren().length == 0) {
		groupQueries.dispose();
	}
	
	if (groupParameters.getChildren().length == 0) {
		groupParameters.dispose();
	}
	
	/* */
	Collection<CouchExtraVariable> extraVariables = null;
	if (couchDbTransaction instanceof PostBulkDocumentsTransaction){
		extraVariables = ((PostBulkDocumentsTransaction) couchDbTransaction).getCouchParametersExtra();
	}
	if (couchDbTransaction instanceof PostDocumentTransaction) {
		extraVariables = ((PostDocumentTransaction) couchDbTransaction).getCouchParametersExtra();
	}
	if (couchDbTransaction instanceof PostUpdateTransaction) {
		extraVariables = ((PostUpdateTransaction) couchDbTransaction).getCouchParametersExtra();
	}
	if (couchDbTransaction instanceof PutUpdateTransaction) {
		extraVariables = ((PutUpdateTransaction) couchDbTransaction).getCouchParametersExtra();
	}
	
	if (extraVariables != null ){
		for (CouchExtraVariable extraVariable : extraVariables) {
			addToComposite(groupData, extraVariable.getVariableName(), extraVariable.getVariableDescription(), extraVariable.isMultiValued());
		}
	}
	
	if (groupData.getChildren().length == 0){
		groupData.dispose();
	}
	
	setContent(globalComposite);
	globalComposite.pack(true);
	
	// Fix text no displayed in C8oBrowser
	LinkedList<Control> controls = new LinkedList<>();
	controls.add(globalComposite);
	Control c;
	while ((c = controls.pollFirst()) != null) {
		if (c instanceof C8oBrowser) {
			((C8oBrowser) c).reloadText();
		} else if (c instanceof Composite) {
			controls.addAll(Arrays.asList(((Composite) c).getChildren()));
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:68,代码来源:CouchVariablesComposite.java

示例6: onBlockBreak

import java.util.LinkedList; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
    World world = event.getWorld();
    IBlockState state = world.getBlockState(event.getPos());
    BlockPos pos = event.getPos();
    if (!state.getBlock().isWood(world, pos)) {
        return;
    }
    int radius = 16;
    int dirX = Math.max(-1, Math.min(1, pos.getX() - (int)Math.round(event.getPlayer().posX - 0.5)));
    int dirZ = Math.max(-1, Math.min(1, pos.getZ() - (int)Math.round(event.getPlayer().posZ - 0.5)));
    LinkedList<BlockPos> queue = new LinkedList<BlockPos>();
    HashMap<BlockPos, Integer> used = new HashMap<BlockPos, Integer>();
    queue.add(pos);
    int leaf = 5;
    used.put(pos, leaf);
    while (!queue.isEmpty()) {
        BlockPos top = queue.pollFirst();
        for (int dx = -1; dx <= 1; ++dx) {
            for (int dy = -1; dy <= 1; ++dy) {
                for (int dz = -1; dz <= 1; ++dz) {
                    BlockPos nPos = top.add(dx, dy, dz);
                    int step = used.get(top);
                    if (step <= 0 || nPos.distanceSq(pos) > radius * radius) {
                        continue;
                    }
                    IBlockState nState = world.getBlockState(nPos);
                    boolean log = nState.getBlock().isWood(world, nPos);
                    boolean leaves = nState.getBlock().isLeaves(nState, world, nPos);
                    if ((dy >= 0 && step == leaf && log) || leaves) {
                        step = step - (leaves ? 1 : 0);
                        if (!used.containsKey(nPos) || used.get(nPos) < step) {
                            used.put(nPos, step);
                            queue.push(nPos);
                        }
                    }
                }
            }
        }
    }
    for (Map.Entry<BlockPos, Integer> entry : used.entrySet()) {
        BlockPos blockPos = entry.getKey();
        if (!pos.equals(blockPos) && isDraggable(world, blockPos.add(0, -1, 0))) {
            int oy = blockPos.getY() - pos.getY();
            drop(world, blockPos, blockPos.add(oy * dirX, 0, oy * dirZ));
        }
    }
}
 
开发者ID:ternsip,项目名称:ChopDown,代码行数:49,代码来源:ChopDown.java

示例7: bfs

import java.util.LinkedList; //导入方法依赖的package包/类
void bfs(Writer w, Object root) throws IOException {
  if (root == null || isPrimitiveOrWrapper(root.getClass())) {
    return;
  }
  LinkedList<Object> queue = new LinkedList<Object>();
  Map seen = new java.util.IdentityHashMap();

  seen.put(root, null);

  // Adds to end of queue
  queue.addFirst(root);

  while (!queue.isEmpty()) {

    // removes from front of queue
    Object r = queue.pollFirst();
    List<Object> childrens = getChildrens(w, r);
    // Visit child first before grand child
    for (Object n : childrens) {

      if (n == null) {
        continue;
      }
      if (!isPrimitiveOrWrapper(n.getClass())) {
        if (!seen.containsKey(n)) {
          queue.addFirst(n);
          seen.put(n, null);
        } else {
          List<Object> list = forbidden.get(r);
          if (list != null) {
            list.add(n);
            forbidden.put(r, list);
          } else {
            List<Object> newList = new ArrayList<Object>();
            newList.add(n);
            forbidden.put(r, newList);
          }

        }
      }

    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:45,代码来源:TypedJson.java


注:本文中的java.util.LinkedList.pollFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。