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