java.util.LinkedList#remove ( )源码实例Demo

下面列出了java.util.LinkedList#remove ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CEventCenter   文件: CEventCenter.java
/**
 * 注销监听器
 *
 * @param listener 监听器
 * @param topics   多个主题
 */
public static void unregisterEventListener(I_CEventListener listener, String[] topics) {
    if (null == listener || null == topics) {
        return;
    }
    synchronized (LISTENER_LOCK) {
        for (String topic : topics) {
            if (TextUtils.isEmpty(topic)) {
                continue;
            }
            Object obj = LISTENER_MAP.get(topic);
            if (null == obj) {
                continue;
            } else if (obj instanceof I_CEventListener) {
                // 有一个监听器
                if (obj == listener) {
                    LISTENER_MAP.remove(topic);
                }
            } else if (obj instanceof List) {
                // 有多个监听器
                LinkedList<I_CEventListener> listeners = (LinkedList<I_CEventListener>) obj;
                listeners.remove(listener);
            }
        }
    }
}
 
/**
 * Saves the history of this control.
 */
public void saveHistory() {
	final IDialogSettings settings= fWizard.getDialogSettings();
	if (settings != null) {
		final LinkedList<String> locations= new LinkedList<String>();
		final String[] items= fCombo.getItems();
		for (int index= 0; index < items.length; index++)
			locations.add(items[index]);
		final String text= fCombo.getText().trim();
		if (!"".equals(text)) { //$NON-NLS-1$
			locations.remove(text);
			locations.addFirst(text);
		}
		final int size= locations.size();
		for (int index= 0; index < size - MAX_HISTORY_SIZE; index++)
			locations.removeLast();
		settings.put(fKey, locations.toArray(new String[locations.size()]));
	}
}
 
源代码3 项目: brickkit-android   文件: BrickDataManager.java
/**
 * Removes a brick with a tag from the cache.
 *
 * @param item the Brick
 */
public void removeFromTagCache(@NonNull BaseBrick item) {
    synchronized (this.tagCache) {
        if (item.getTag() != null && this.tagCache.containsKey(item.getTag())) {
            LinkedList<BaseBrick> list = this.tagCache.get(item.getTag());
            if (null == list) {
                Log.w(TAG, "removeFromTagCache: The tag cache is null.");
                return; // safety
            }

            list.remove(item);

            if (list.size() == 0) {
                this.tagCache.remove(item.getTag());
            }
        }
    }
}
 
源代码4 项目: openjdk-jdk9   文件: LinkedListTest.java
/**
 * 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) {}
}
 
源代码5 项目: Siamese   文件: RailRoadCar.java
private static LinkedList a ( LinkedList list ) {
    System.out.println ( "Rearranging Cars..." );
    new LinkedList();
    final LinkedList<Object> list2 = new LinkedList<Object>();
    final LinkedList<Object> list3 = new LinkedList<Object>();
    final LinkedList<Object> list4 = new LinkedList<Object>();
    list = list;
    int size;
    while ( ( size = list.size() ) != 0 ) {
        for ( int i = 0; i < size; ++i ) {
            if ( i == 0 ) {
                list3.add ( list.element() );
                list.remove();
            } else if ( Integer.parseInt ( list3.element().toString() ) < Integer.parseInt ( list.element().toString() ) ) {
                list2.add ( list3.element() );
                list3.remove();
                list3.add ( list.element() );
                list.remove();
            } else {
                list2.add ( list.element() );
                list.remove();
            }
        }
        for ( int size2 = list2.size(), j = 0; j < size2; ++j ) {
            list.add ( list2.element() );
            list2.remove();
        }
        list4.add ( list3.element() );
        list3.remove();
        System.out.print ( list.toString() );
        System.out.print ( " , " );
        System.out.print ( list2.toString() );
        System.out.print ( " , " );
        System.out.print ( list3.toString() );
        System.out.print ( " , " );
        System.out.println ( list4.toString() );
    }
    return list4;
}
 
源代码6 项目: ict   文件: RandomTopologyTest.java
@Test
public void testRandomNetworkTopologies() {
    List<Ict> network = createRandomNetworkTopology(10);
    randomlyConnectIcts(network, 3);
    Ict randomIct = network.get((int) (Math.random() * network.size()));
    LinkedList<Ict> otherIcts = new LinkedList<>(network);
    otherIcts.remove(randomIct);
    testCommunicationRange(randomIct, otherIcts, 20);
}
 
源代码7 项目: BmapLite   文件: CacheInteracter.java
public void addSearchHistoryKeyword(String keyword) {
    LinkedList<String> historyList = getSearchHistoryKeyword();
    if (null == historyList) {
        historyList = new LinkedList<>();
    }
    if (historyList.contains(keyword)) {
        historyList.remove(keyword);
    }
    historyList.addFirst(keyword);

    setSearchHistoryKeyword(historyList);
}
 
源代码8 项目: BmapLite   文件: CacheInteracter.java
public void deleteSearchHistoryKeyword(String keyword) {
    if (null == keyword || keyword.isEmpty()) {
        return;
    }
    LinkedList<String> historyList = getSearchHistoryKeyword();
    if (null == historyList) {
        return;
    }
    historyList.remove(keyword);

    setSearchHistoryKeyword(historyList);
}
 
源代码9 项目: BmapLite   文件: CacheInteracter.java
public void deleteRouteHistory(RouteHistoryModel history) throws JSONException {
    if (null == history) {
        return;
    }
    LinkedList<RouteHistoryModel> historyList = getRouteHistory();
    if (null == historyList) {
        return;
    }
    historyList.remove(history);

    setRouteHistory(historyList);
}
 
源代码10 项目: spring-cloud-contract   文件: XmlAsserter.java
String createXPathString(LinkedList<String> buffer) {
	LinkedList<String> queue = new LinkedList<String>(buffer);
	StringBuilder stringBuffer = new StringBuilder();
	while (!queue.isEmpty()) {
		String value = queue.remove();
		if (!(queue.isEmpty() && value.equals("/"))) {
			stringBuffer.append(value);
		}
	}
	return stringBuffer.toString();
}
 
源代码11 项目: leakcanary-for-eclipse   文件: ObjectCache.java
protected void revalueEntry(Entry<E> entry)
{
    LinkedList<Entry<E>> currBucket = lfu(entry.numUsages);
    LinkedList<Entry<E>> nextBucket = lfu(++entry.numUsages);

    currBucket.remove(entry);
    nextBucket.addFirst(entry);
}
 
源代码12 项目: termsuite-core   文件: BilingualAlignmentService.java
/**
 * E.g. Given the compound [hydro|électricité] and the component [hydro], the method should return the 
 * term [électricité]
 * 
 * 
 * @param termino
 * @param compound
 * @param component
 * @return
 */
public Collection<TermService> getMorphologicalExtensionsAsTerms(
		TerminologyService terminoService, 
		TermIndex lemmaLowerCaseIndex, 
		TermService compound, 
		Component component) {
	Preconditions.checkArgument(compound.isSingleWord());
	Preconditions.checkArgument(compound.isCompound());
	Preconditions.checkArgument(compound.getWords().get(0).getWord().getComponents().contains(component));
	
	Word compoundWord = compound.getWords().get(0).getWord();
	LinkedList<Component> extensionComponents = Lists.newLinkedList(compoundWord.getComponents());
	extensionComponents.remove(component);
	
	if(!(component.getBegin() == 0 || component.getEnd() == compound.getLemma().length()))
		return Lists.newArrayList();

	
	Set<String> possibleExtensionLemmas = Sets.newHashSet();
	possibleExtensionLemmas.add(compound.getLemma().substring(
			extensionComponents.getFirst().getBegin(), 
			extensionComponents.getLast().getEnd()));
		
	if(extensionComponents.size() > 1) {
		LinkedList<Component> allButLast = Lists.newLinkedList(extensionComponents);
		Component last = allButLast.removeLast();
		String lemma = compound.getLemma().substring(allButLast.getFirst().getBegin(), last.getBegin())
					+ last.getLemma();
		possibleExtensionLemmas.add(lemma);
	}
	
	List<TermService> extensionTerms = Lists.newArrayList();
	for(String s:possibleExtensionLemmas) 
		for(Term term:lemmaLowerCaseIndex.getTerms(s.toLowerCase()))
			extensionTerms.add(terminoService.asTermService(term));
	
	return extensionTerms;
}
 
源代码13 项目: EhViewer   文件: DownloadManager.java
public void deleteRangeDownload(LongList gidList) {
    stopRangeDownloadInternal(gidList);

    for (int i = 0, n = gidList.size(); i < n; i++) {
        long gid = gidList.get(i);
        DownloadInfo info = mAllInfoMap.get(gid);
        if (null == info) {
            Log.d(TAG, "Can't get download info with gid: " + gid);
            continue;
        }

        // Remove from DB
        EhDB.removeDownloadInfo(info.gid);

        // Remove from all info map
        mAllInfoList.remove(info);
        mAllInfoMap.remove(info.gid);

        // Remove from label list
        LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
        if (list != null) {
            list.remove(info);
        }
    }

    // Update listener
    for (DownloadInfoListener l: mDownloadInfoListeners) {
        l.onReload();
    }

    // Ensure download
    ensureDownload();
}
 
源代码14 项目: chipster   文件: Histogram.java
private FloatArrayList getHistogram(int histogramSteps, String expression) throws MicroarrayException, IOException {

		// get data
		Iterable<Float> intensities = data.queryFeatures(expression).asFloats();
		LinkedList<Float> values = new LinkedList<Float>();
		for (float intensity : intensities) {
			values.add(intensity);
		}

		// sort it, so we don't have to search for value intervals
		Collections.sort(values);

		// filter out NaN's
		while (values.get(values.size() - 1).isNaN()) {
			values.remove(values.size() - 1);
		}

		if (values.size() < histogramSteps) {
			return new FloatArrayList(values); // can't make histogram, return
												// plain values
		}

		// determine step size
		float min = values.get(0);
		float max = values.get(values.size() - 1);
		float stepSize = (max - min) / ((float) histogramSteps);

		// initialise
		float[] histogram = new float[histogramSteps];
		int valueIndex = 0;
		float roof = min + stepSize;

		// step through categories, counting matching values as we go
		for (int step = 0; step < histogram.length; step++) {
			while (valueIndex < values.size() && values.get(valueIndex) <= roof) {
				histogram[step]++;
				valueIndex++;
			}
			roof += stepSize;
		}

		// add to last category what was left out
		histogram[histogram.length - 1] += (values.size() - valueIndex);

		return new FloatArrayList(histogram);
	}
 
源代码15 项目: jsoup-learning   文件: HtmlTreeBuilder.java
private void replaceInQueue(LinkedList<Element> queue, Element out, Element in) {
    int i = queue.lastIndexOf(out);
    Validate.isTrue(i != -1);
    queue.remove(i);
    queue.add(i, in);
}
 
源代码16 项目: openjdk-jdk8u   文件: Options.java
private void processArgList(final LinkedList<String> argList) {
    while (!argList.isEmpty()) {
        final String arg = argList.remove(0);

        // skip empty args
        if (arg.isEmpty()) {
            continue;
        }

        // user arguments to the script
        if ("--".equals(arg)) {
            arguments.addAll(argList);
            argList.clear();
            continue;
        }

        // If it doesn't start with -, it's a file. But, if it is just "-",
        // then it is a file representing standard input.
        if (!arg.startsWith("-") || arg.length() == 1) {
            files.add(arg);
            continue;
        }

        if (arg.startsWith(definePropPrefix)) {
            final String value = arg.substring(definePropPrefix.length());
            final int eq = value.indexOf('=');
            if (eq != -1) {
                // -Dfoo=bar Set System property "foo" with value "bar"
                System.setProperty(value.substring(0, eq), value.substring(eq + 1));
            } else {
                // -Dfoo is fine. Set System property "foo" with "" as it's value
                if (!value.isEmpty()) {
                    System.setProperty(value, "");
                } else {
                    // do not allow empty property name
                    throw new IllegalOptionException(definePropTemplate);
                }
            }
            continue;
        }

        // it is an argument,  it and assign key, value and template
        final ParsedArg parg = new ParsedArg(arg);

        // check if the value of this option is passed as next argument
        if (parg.template.isValueNextArg()) {
            if (argList.isEmpty()) {
                throw new IllegalOptionException(parg.template);
            }
            parg.value = argList.remove(0);
        }

        // -h [args...]
        if (parg.template.isHelp()) {
            // check if someone wants help on an explicit arg
            if (!argList.isEmpty()) {
                try {
                    final OptionTemplate t = new ParsedArg(argList.get(0)).template;
                    throw new IllegalOptionException(t);
                } catch (final IllegalArgumentException e) {
                    throw e;
                }
            }
            throw new IllegalArgumentException(); // show help for
            // everything
        }

        if (parg.template.isXHelp()) {
            throw new IllegalOptionException(parg.template);
        }

        set(parg.template.getKey(), createOption(parg.template, parg.value));

        // Arg may have a dependency to set other args, e.g.
        // scripting->anon.functions
        if (parg.template.getDependency() != null) {
            argList.addFirst(parg.template.getDependency());
        }
    }
}
 
源代码17 项目: javagame   文件: MainPanel.java
/**
 * �Q�[�����[�v
 */
public void run() {
    while (true) {
        if (goLeftKey.isPressed()) {
            // ���L�[��������Ă���΍������ɉ���
            player.accelerateLeft();
        } else if (goRightKey.isPressed()) {
            // �E�L�[��������Ă���ΉE�����ɉ���
            player.accelerateRight();
        } else {
            // ����������ĂȂ��Ƃ��͒�~
            player.stop();
        }

        if (jumpKey.isPressed()) {
            // �W�����v����
            player.jump();
        }

        // �v���C���[�̏�Ԃ��X�V
        player.update();

        // �}�b�v�ɂ���X�v���C�g���擾
        LinkedList sprites = map.getSprites();            
        Iterator iterator = sprites.iterator();
        while (iterator.hasNext()) {
            Sprite sprite = (Sprite)iterator.next();
            
            // �X�v���C�g�̏�Ԃ��X�V����
            sprite.update();

            // �v���C���[�ƐڐG���Ă���
            if (player.isCollision(sprite)) {
                if (sprite instanceof Kuribo) {  // �I�{�[
                    Kuribo kuribo = (Kuribo)sprite;
                    // �ォ�瓥�܂�Ă���
                    if ((int)player.getY() < (int)kuribo.getY()) {
                        // �I�{�[�͏�����
                        sprites.remove(kuribo);
                        // �T�E���h
                        kuribo.play();
                        // ���ނƃv���C���[�͍ăW�����v
                        player.setForceJump(true);
                        player.jump();
                        break;
                    } else {
                        // �Q�[���I�[�o�[
                        gameOver();
                    }
                } else if (sprite instanceof Coin) {  // �R�C��
                        Coin coin = (Coin)sprite;
                        // �R�C���͏�����
                        sprites.remove(coin);
                        // �����`��
                        coin.play();
                        // sprites����폜�����̂�
                        // break���Ȃ���iterator�����������Ȃ�
                        break;
                } else if (sprite instanceof Accelerator) {  // �����A�C�e��
                    // �A�C�e���͏�����
                    sprites.remove(sprite);
                    Accelerator accelerator = (Accelerator)sprite;
                    // �T�E���h
                    accelerator.play();
                    // �A�C�e�������̏�Ŏg��
                    accelerator.use(player);
                    break;
                } else if (sprite instanceof JumperTwo) {  // ��i�W�����v�A�C�e��
                    // �A�C�e���͏�����
                    sprites.remove(sprite);
                    JumperTwo jumperTwo = (JumperTwo)sprite;
                    // �T�E���h
                    jumperTwo.play();
                    // �A�C�e�������̏�Ŏg��
                    jumperTwo.use(player);
                    break;                        
                }
            }
        }
        
        // �ĕ`��
        repaint();

        // �x�~
        try {
            Thread.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
 
源代码18 项目: netbeans   文件: EnableBeansFilter.java
private void checkProxyability( TypeElement typeElement,
        LinkedList<Element> types , Set<Element> elements)
{
    try {
        String scope = ParameterInjectionPointLogic.getScope(typeElement,
                getWebBeansModel().getHelper());
        Elements elementsUtil = getHelper().getCompilationController().
            getElements();
        TypeElement scopeElement = elementsUtil.getTypeElement(scope);
        /*
         * Client proxies are never required for a bean whose
         * scope is a pseudo-scope such as @Dependent.
         */
        if ( scopeElement == null ||
                getHelper().hasAnnotation( elementsUtil.getAllAnnotationMirrors(
                scopeElement), SCOPE) )
        {
            return;
        }
    }
    catch (CdiException e) {
        types.remove( typeElement );
        elements.remove( typeElement);
        return;
    }
    /*
     * Certain legal bean types cannot be proxied by the container:
     * - classes which don't have a non-private constructor with no parameters,
     * - classes which are declared final or have final methods,
     * - primitive types,
     * -  and array types.
     */
    if ( hasModifier(typeElement, Modifier.FINAL)){
        types.remove(typeElement);
        elements.remove( typeElement );
        return;
    }
    checkFinalMethods(typeElement, types, elements);

    List<ExecutableElement> constructors = ElementFilter.constructorsIn(
            typeElement.getEnclosedElements()) ;
    boolean appropriateCtor = false;
    for (ExecutableElement constructor : constructors) {
        if ( hasModifier(constructor, Modifier.PRIVATE)){
            continue;
        }
        if ( constructor.getParameters().size() == 0 ){
            appropriateCtor = true;
            break;
        }
    }

    if ( !appropriateCtor){
        types.remove(typeElement);
        elements.remove( typeElement );
    }
}
 
源代码19 项目: HtmlUnit-Android   文件: WebConsole.java
/**
 * This method is used by all the public method to process the passed
 * parameters.
 *
 * If the last parameter implements the Formatter interface, it will be
 * used to format the parameters and print the object.
 * @param objs the logging parameters
 * @return a String to be printed using the logger
 */
private String process(final Object[] objs) {
    if (objs == null) {
        return "null";
    }

    final StringBuilder sb = new StringBuilder();
    final LinkedList<Object> args = new LinkedList<>(Arrays.asList(objs));

    final Formatter formatter = getFormatter();

    if (args.size() > 1 && args.get(0) instanceof String) {
        final StringBuilder msg = new StringBuilder((String) args.remove(0));
        int startPos = msg.indexOf("%");

        while (startPos > -1 && startPos < msg.length() - 1 && args.size() > 0) {
            if (startPos != 0 && msg.charAt(startPos - 1) == '%') {
                // double %
                msg.replace(startPos, startPos + 1, "");
            }
            else {
                final char type = msg.charAt(startPos + 1);
                String replacement = null;
                switch (type) {
                    case 'o':
                    case 's':
                        replacement = formatter.parameterAsString(pop(args));
                        break;
                    case 'd':
                    case 'i':
                        replacement = formatter.parameterAsInteger(pop(args));
                        break;
                    case 'f':
                        replacement = formatter.parameterAsFloat(pop(args));
                        break;
                    default:
                        break;
                }
                if (replacement != null) {
                    msg.replace(startPos, startPos + 2, replacement);
                    startPos = startPos + replacement.length();
                }
                else {
                    startPos++;
                }
            }
            startPos = msg.indexOf("%", startPos);
        }
        sb.append(msg);
    }

    for (final Object o : args) {
        if (sb.length() != 0) {
            sb.append(' ');
        }
        sb.append(formatter.printObject(o));
    }
    return sb.toString();
}
 
源代码20 项目: javagame   文件: MainPanel.java
/**
 * �Q�[�����[�v
 */
public void run() {
    while (true) {
        if (leftPressed) {
            // ���L�[��������Ă���΍������ɉ���
            player.accelerateLeft();
        } else if (rightPressed) {
            // �E�L�[��������Ă���ΉE�����ɉ���
            player.accelerateRight();
        } else {
            // ����������ĂȂ��Ƃ��͒�~
            player.stop();
        }

        if (upPressed) {
            // �W�����v����
            player.jump();
        }

        // �v���C���[�̏�Ԃ��X�V
        player.update();

        // �}�b�v�ɂ���X�v���C�g���擾
        LinkedList sprites = map.getSprites();            
        Iterator iterator = sprites.iterator();
        while (iterator.hasNext()) {
            Sprite sprite = (Sprite)iterator.next();
            
            // �X�v���C�g�̏�Ԃ��X�V����
            sprite.update();

            // �v���C���[�ƐڐG���Ă���
            if (player.isCollision(sprite)) {
                if (sprite instanceof Coin) {  // �R�C��
                    Coin coin = (Coin)sprite;
                    // �R�C���͏�����
                    sprites.remove(coin);
                    // �����`��
                    coin.play();
                    // sprites����폜�����̂�
                    // break���Ȃ���iterator�����������Ȃ�
                    break;
                } else if (sprite instanceof Kuribo) {  // �I�{�[
                    Kuribo kuribo = (Kuribo)sprite;
                    // �ォ�瓥�܂�Ă���
                    if ((int)player.getY() < (int)kuribo.getY()) {
                        // �I�{�[�͏�����
                        sprites.remove(kuribo);
                        // �T�E���h
                        kuribo.play();
                        // ���ނƃv���C���[�͍ăW�����v
                        player.setForceJump(true);
                        player.jump();
                        break;
                    } else {
                        // �Q�[���I�[�o�[
                        gameOver();
                    }
                } else if (sprite instanceof Accelerator) {  // �����A�C�e��
                    // �A�C�e���͏�����
                    sprites.remove(sprite);
                    Accelerator accelerator = (Accelerator)sprite;
                    // �T�E���h
                    accelerator.play();
                    // �A�C�e�������̏�Ŏg��
                    accelerator.use(player);
                    break;
                }
            }
        }
        
        // �ĕ`��
        repaint();

        // �x�~
        try {
            Thread.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}