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


Java LinkedList.remove方法代码示例

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


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

示例1: discoverDirectory

import java.util.LinkedList; //导入方法依赖的package包/类
public static Map<FileType, List<File>> discoverDirectory(File directory) {
    Map<FileType, List<File>> candidates = new HashMap<>();
    for (FileType type : FileType.values()) {
        candidates.put(type, Lists.newLinkedList());
    }
    LinkedList<File> directories = Lists.newLinkedList();
    directories.add(directory);
    while (!directories.isEmpty()) {
        File dir = directories.remove(0);
        for (File f : dir.listFiles()) {
            if(f.isDirectory()) {
                directories.addLast(f);
            } else {
                //I am *not* taking chances with this ordering
                if(FileType.VARIABLES.accepts(f.getName())) {
                    candidates.get(FileType.VARIABLES).add(f);
                } else if(FileType.MACHINE.accepts(f.getName())) {
                    candidates.get(FileType.MACHINE).add(f);
                }
            }
        }
    }
    return candidates;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:25,代码来源:MachineLoader.java

示例2: testRetainAll

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * retainAll(c) retains only those elements of c and reports true if changed
 */
public void testRetainAll() {
    LinkedList q = populatedQueue(SIZE);
    LinkedList p = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        boolean changed = q.retainAll(p);
        if (i == 0)
            assertFalse(changed);
        else
            assertTrue(changed);

        assertTrue(q.containsAll(p));
        assertEquals(SIZE - i, q.size());
        p.remove();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:LinkedListTest.java

示例3: moveInputKeyToReplace

import java.util.LinkedList; //导入方法依赖的package包/类
public boolean moveInputKeyToReplace(InputKeyReference inputKeyRefSrc)	{
	if (!isValid() || inputKeyRefSrc == null || !inputKeyRefSrc.isValid())	{
		return false;
	} else if (isSame(inputKeyRefSrc))	{
		return true;	// move itself to replace itself, do nothing.
	}
	InputKey inputKeySrc = inputKeyRefSrc.getInputKey();
	InputKey inputKeyDest = getInputKey();
	inputKeyDest.copy(inputKeySrc);
	LinkedList<InputKey> listInputKeysSrc;
	if (!inputKeyRefSrc.mbIsLand)	{
		listInputKeysSrc = mlistInputPads.get(inputKeyRefSrc.mnInputPadIdx).getListOfKeys();
	} else	{
		listInputKeysSrc = mlistInputPads.get(inputKeyRefSrc.mnInputPadIdx).getListOfKeysLand();
	}
	listInputKeysSrc.remove(inputKeyRefSrc.mnInputKeyIdx);
	updateInputPadKeys(inputKeyRefSrc.mnInputPadIdx, listInputKeysSrc, inputKeyRefSrc.mbIsLand);
	return true;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:20,代码来源:ActivityCfgKeyPad.java

示例4: addHistoryEntry

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Adds newEntry to the front of history XML.
 * Removes elements that exceed size limit from the back of the list.
 * @throws IOException
 */
public void addHistoryEntry(String newEntry) throws IOException {
    LinkedList<String> historyEntries = getHistory();
    if (historyEntries == null) {
        historyEntries = new LinkedList<>();
    }
    if (!newEntry.isEmpty()) {

        historyEntries.remove(newEntry);
        historyEntries.add(0, newEntry);
        while (historyEntries.size() > maxEntries) {
            historyEntries.removeLast();
        }

        dumpListToFile(historyEntries);
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:22,代码来源:XmlHistory.java

示例5: flush

import java.util.LinkedList; //导入方法依赖的package包/类
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:18,代码来源:SyncRequestProcessor.java

示例6: getRemovedSymmetryGraph

import java.util.LinkedList; //导入方法依赖的package包/类
public TreeMap<T, LinkedList<Edge>> getRemovedSymmetryGraph() {
	if(graphType != GraphType.UNDIRECTED)
		return edgesByVertices;
	
	TreeMap<T, LinkedList<Edge>> edgesByVertexes_copy = new TreeMap<>();
	edgesByVertexes_copy.putAll(edgesByVertices);
	
	// 대칭 그래프 삭제
	for(LinkedList<Edge> edges1 : edgesByVertices.values()) {
		
		for(Edge edge1 : edges1) {
			
			LinkedList<Edge> edges2 = edgesByVertexes_copy.get(edge1.getToVertex());
			for(int i=0 ; i<edges2.size() ; i++) {
				
				Edge edge2 = edges2.get(i);
				if(edge2.getToVertex().equals(edge1.getFromVertex()))
					edges2.remove();
				
			}
		}
	}
	
	return edgesByVertexes_copy;
}
 
开发者ID:xeyez,项目名称:StationGraph,代码行数:26,代码来源:AbstractGraph.java

示例7: processQueueMessages

import java.util.LinkedList; //导入方法依赖的package包/类
private void processQueueMessages() {
  LinkedList<BPServiceActorAction> duplicateQueue;
  synchronized (bpThreadQueue) {
    duplicateQueue = new LinkedList<BPServiceActorAction>(bpThreadQueue);
    bpThreadQueue.clear();
  }
  while (!duplicateQueue.isEmpty()) {
    BPServiceActorAction actionItem = duplicateQueue.remove();
    try {
      actionItem.reportTo(bpNamenode, bpRegistration);
    } catch (BPServiceActorActionException baae) {
      LOG.warn(baae.getMessage() + nnAddr , baae);
      // Adding it back to the queue if not present
      bpThreadEnqueue(actionItem);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:BPServiceActor.java

示例8: traverseComponent

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
protected void traverseComponent(byte nodeID, Graph graph) {

  LinkedList<Byte> toExploreQ = new LinkedList<Byte>();
  // start a component traversal
  visit(STATUS_START_COMPONENT);
  // visit the node and update the seen nodes
  visit(nodeID);
  // queue the visited node for exploration of its neighbors
  toExploreQ.add(nodeID);
  // done when:
  // (1) all nodes seen OR
  // (2) no new nodes to explore in this connected component
  while (!seenAll() && !toExploreQ.isEmpty()) {
    // remove the first node to explore from the queue
    byte explore = toExploreQ.remove();
    // visit every unseen neighbor and enqueue them for traversal
    for (byte i = 0; i < graph.getOutDegree(explore); i++) {
      byte neighbor = graph.getOutNode(explore, i);
      if (unseenNeighbor(explore, neighbor)) {
        visit(neighbor);
        toExploreQ.add(neighbor);
      }
    }
  }
  // this component has been visited
  visit(STATUS_VISITED_COMPONENT);
}
 
开发者ID:etomica,项目名称:etomica,代码行数:29,代码来源:BreadthFirst.java

示例9: fillSubTypes

import java.util.LinkedList; //导入方法依赖的package包/类
private List<DeclaredType> fillSubTypes(CompilationController cc, DeclaredType dType) {
    List<DeclaredType> subtypes = new ArrayList<>();
    //Set<? extends SearchScopeType> scope = Collections.singleton(new ClassSearchScopeType(prefix));
    Types types = cc.getTypes();
    if (prefix != null && prefix.length() > 2 && lastPrefixDot < 0) {
        //Trees trees = cc.getTrees();
        ClassIndex.NameKind kind = ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX;
        for (ElementHandle<TypeElement> handle : cpi.getClassIndex().getDeclaredTypes(prefix, kind, EnumSet.allOf(ClassIndex.SearchScope.class))) {
            TypeElement te = handle.resolve(cc);
            if (te != null && /*trees.isAccessible(scope, te) &&*/ types.isSubtype(types.getDeclaredType(te), dType)) {
                subtypes.add(types.getDeclaredType(te));
            }
        }
    } else {
        HashSet<TypeElement> elems = new HashSet<>();
        LinkedList<DeclaredType> bases = new LinkedList<>();
        bases.add(dType);
        ClassIndex index = cpi.getClassIndex();
        while (!bases.isEmpty()) {
            DeclaredType head = bases.remove();
            TypeElement elem = (TypeElement) head.asElement();
            if (!elems.add(elem)) {
                continue;
            }
            if (accept(elem)) {
                subtypes.add(head);
            }
            //List<? extends TypeMirror> tas = head.getTypeArguments();
            //boolean isRaw = !tas.iterator().hasNext();
            for (ElementHandle<TypeElement> eh : index.getElements(ElementHandle.create(elem), EnumSet.of(ClassIndex.SearchKind.IMPLEMENTORS), EnumSet.allOf(ClassIndex.SearchScope.class))) {
                TypeElement e = eh.resolve(cc);
                if (e != null) {
                    DeclaredType dt = types.getDeclaredType(e);
                    bases.add(dt);
                }
            }
        }
    }
    return subtypes;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:ExceptionCompletionProvider.java

示例10: testRemove

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * remove removes next element, or throws NSEE if empty
 */
public void testRemove() {
    LinkedList q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.remove());
    }
    try {
        q.remove();
        shouldThrow();
    } catch (NoSuchElementException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:LinkedListTest.java

示例11: removeDefaultFilters

import java.util.LinkedList; //导入方法依赖的package包/类
public static void removeDefaultFilters(LinkedList<Filter> filterList,
										int numberOfJugglers, int minThrow) {
	if (numberOfJugglers <= 1)
		return;
	while (filterList.remove(new NumberFilter(Siteswap.PASS, Type.GREATER_EQUAL, 1)))
		;
	for (int i = minThrow; i < 2*numberOfJugglers; ++i) {
		if ( Siteswap.isPass(i, numberOfJugglers))
			while (filterList.remove(new NumberFilter(i, Type.EQUAL, 0)))
				;
	}
}
 
开发者ID:namlit,项目名称:siteswap_generator,代码行数:13,代码来源:Filter.java

示例12: createRule

import java.util.LinkedList; //导入方法依赖的package包/类
Rule createRule(final String pattern, final Capabilities capabilities) {

        final List<String> parts = getParts(pattern);
        if (parts.isEmpty()) {
            throw new IllegalStateException();
        }

        final String first = parts.get(0);
        if (parts.size() == 1) {
            if ("*".equals(first)) {
                return getWildCardRule();
            }
            return new Rule(getLiteral(first), null, null, pattern, capabilities);
        }

        final LinkedList<String> suffixes = new LinkedList<>(parts);

        Literal prefix = null;
        if (!"*".equals(first)) {
            prefix = getLiteral(first);
            suffixes.remove(0);
        }

        final String last = parts.get(parts.size() - 1);
        Literal postfix = null;
        if (!"*".equals(last)) {
            postfix = getLiteral(last);
            suffixes.removeLast();
        }
        suffixes.removeAll(singleton("*"));
        final Literal[] suffixArray = new Literal[suffixes.size()];
        for (int i = 0; i < suffixArray.length; i++) {
            suffixArray[i] = getLiteral(suffixes.get(i));
        }

        return new Rule(prefix, suffixArray, postfix, pattern, capabilities);
    }
 
开发者ID:blueconic,项目名称:browscap-java,代码行数:38,代码来源:UserAgentFileParser.java

示例13: removeClientId

import java.util.LinkedList; //导入方法依赖的package包/类
public static void removeClientId(String clientId) {
    Iterator<LinkedList<Message>> collection = container.values().iterator();
    LinkedList<Message> messages;
    Message message = new Message();
    message.setClientId(clientId);
    while (collection.hasNext()) {
        messages = collection.next();
        if (messages.contains(message)) {
            messages.remove(message);
        }
    }
}
 
开发者ID:airballcz,项目名称:iot-platform,代码行数:13,代码来源:SubscribeContainer.java

示例14: populatePredicates

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * input query = field:abcAND(field<bcdOR(field:defANDfield>=efg))
 * return field:abc,field<bcd,field:def,field>=efg,AND,OR,AND
 * @param root 
 * @param query
 * @param predicates 
 * @return 
 * @return
 */
private Predicate populatePredicates(Root<T> root, String query)
{
	if(StringUtils.countOccurrencesOf(query, Conjunctions.SP.toString()) == StringUtils.countOccurrencesOf(query, Conjunctions.EP.toString())) {
		LinkedList<String> postfix = createPostfixExpression(query);
		boolean hasSingleSearchField = postfix.size() == 1;  
		
		Map<String, Predicate> predicateMap = new LinkedHashMap<>();
		
		for (int i = 0; i < postfix.size(); i++)
		{
			String attr = postfix.get(i);
			if(Conjunctions.isConjunction(attr)) {
				
				String rightOperand = postfix.get(i-1);
				String leftOperand = postfix.get(i-2);
				
				String key = rightOperand + attr + leftOperand;
				
				Predicate rightPredicate = (predicateMap.containsKey(rightOperand))? predicateMap.get(rightOperand) : buildPredicate(root, new SearchField(rightOperand)); 
				
				Predicate leftPredicate = (predicateMap.containsKey(leftOperand))? predicateMap.get(leftOperand) : buildPredicate(root, new SearchField(leftOperand));
				
				postfix.set(i-2, key);
				postfix.remove(i);
				postfix.remove(i-1);
				
				//reset loop
				i=0;
				
				List<Predicate> combinedPredicates = new ArrayList<>();
				combinedPredicates.add(leftPredicate);
				combinedPredicates.add(rightPredicate);
				
				Predicate combinedPredicate = buildPredicateWithOperator(root, Conjunctions.getEnum(attr), combinedPredicates);
				predicateMap.put(key, combinedPredicate);
			}
		}
		
		if(hasSingleSearchField) {
			SearchField field = new SearchField(postfix.get(0));
			predicateMap.put(postfix.get(0), buildPredicate(root, field));
		}
		
		return (Predicate) predicateMap.values().toArray()[predicateMap.size()-1];
	} else {
		throw new RuntimeException("MALFORMED.QUERY");
	}
}
 
开发者ID:tairmansd,项目名称:CriteriaBuilder,代码行数:58,代码来源:CriteriaServiceImpl.java

示例15: 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


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